diff --git a/home_external/.bash_aliases b/home_external/.bash_aliases index 97b906c..a108d99 100644 --- a/home_external/.bash_aliases +++ b/home_external/.bash_aliases @@ -31,6 +31,17 @@ alias fssizes='df -kh --output=size,used,avail,pcent,target | sort -hr' alias dirsizes='du -kh --apparent-size --max-depth=1 | sort -hr' +updateSystem() { + executeAndNotify "doUpdateSystem $1" "system updated" "system update failed" +} + + +doUpdateSystem() { + updatePackages $1; + updateFlatpak $1; +} + + updateFlatpak() { noconfirm= if [[ $1 == "-y" ]]; then @@ -42,7 +53,7 @@ updateFlatpak() { doUpdateFlatpak() { flatpak update $1; - flatpak remove --unused $1 + flatpak remove --unused $1; } @@ -50,10 +61,10 @@ doUpdateFlatpak() { execute() { dir="$(pwd)"; dir=${dir##*/}; - if [ -n "$2" ]; then - errLog=$2 + if [[ -n "$2" ]]; then + errLog=$2; else - errLog="execution of \"$1\" failed" + errLog="execution of \"$1\" failed"; fi if ! $1; then @@ -67,32 +78,32 @@ execute() { executeAndNotify () { dir="$(pwd)"; dir=${dir##*/}; - if [ -n "$2" ]; then - winLog=$2 + if [[ -n "$2" ]]; then + winLog=$2; else - winLog="execution of \"$1\" succeeded" + winLog="execution of \"$1\" succeeded"; fi if ! execute "$1" "$3"; then # arguments in quotes so they are interpreted as ONE argument each by execute() return 1; fi - notifyInfo "$dir: $winLog" + notifyInfo "$dir: $winLog"; } # find file but don't print errors (e.g. can't access directory etc.) finds () { - find $* 2>/dev/null + find $* 2>/dev/null; } # sends a desktop-notification with an icon signalling an error notifyError () { - notify-send "$1" --icon=data-warning + notify-send "$1" --icon=data-warning; } # sends a desktop-notification with an icon signalling a simple information notifyInfo () { - notify-send "$1" --icon=preferences-desktop-notification + notify-send "$1" --icon=preferences-desktop-notification; } diff --git a/home_external/.bash_aliases_branched b/home_external/.bash_aliases_branched new file mode 100644 index 0000000..c2539e2 --- /dev/null +++ b/home_external/.bash_aliases_branched @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + + +updatePackages() { + noconfirm= + if [[ $1 == "-y" ]]; then + noconfirm="--no-confirm"; + fi + executeAndNotify "doUpdatePackages $noconfirm" "packages updated" "package update failed"; +} + + +doUpdatePackages() { + pamac update $1; + pamac remove --orphans --cascade $1; +} diff --git a/home_external/.bash_aliases_extra b/home_external/.bash_aliases_extra deleted file mode 100644 index f1f641a..0000000 --- a/home_external/.bash_aliases_extra +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/env bash