From c2bd45267a64778655e2a75e364170315d3ee81e Mon Sep 17 00:00:00 2001 From: fabian Date: Wed, 19 Nov 2025 20:57:16 +0100 Subject: [PATCH] Revert "- removed debug ouptut" This reverts commit 4c09537776022a1c69134ab24ed307644136f2e1. --- home_external/.bash_aliases | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/home_external/.bash_aliases b/home_external/.bash_aliases index 7ee9e72..049b310 100644 --- a/home_external/.bash_aliases +++ b/home_external/.bash_aliases @@ -40,6 +40,11 @@ alias dirsizes='du -kh --apparent-size --max-depth=1 | sort -hr' alias start_x11_vnc="x11vnc -many -display :0 -no6 -rfbport 5900 -auth /var/run/lightdm/root/:0 -rfbauth $HOME/.vnc/passwd" +commandExists() { + type $1 2 >& 1 > /dev/null +} + + rsyncLink() { source=$1; linkSource="$(realpath $source)"; @@ -47,18 +52,25 @@ rsyncLink() { shift; dest=$1; shift; - echo "rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*;" rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*; } updateSystem() { + executeAndNotify "doUpdateSystem $1" "system updated" "system update failed" +} + + +doUpdateSystem() { updatePackages $1; updateFlatpak $1; } updateFlatpak() { + if [[ ! $(commandExists flatpak) ]]; then + return 1; + fi noconfirm= if [[ $1 == "-y" ]]; then noconfirm="--assumeyes"; @@ -76,7 +88,7 @@ doUpdateFlatpak() { # executes command and notifies upon failure execute() { dir="$(pwd)"; - dir=${dir##*/}; + dir=${dir##*/}; # cut off previous path (/path/to/foo.txt -> foo.txt) if [[ -n "$2" ]]; then errLog=$2; else @@ -100,17 +112,9 @@ executeAndNotify () { winLog="execution of \"$1\" succeeded"; fi - echo "" - echo "******************************************" - echo "executeAndNotify \"$1\" \"$winLog\" \"$3\"" - echo "******************************************" - echo "" - if ! execute "$1" "$3"; then # arguments in quotes so they are interpreted as ONE argument each by execute() - echo "failed \"$1\" -> \"$3\"" return 1; fi - echo "succeeded \"$1\" -> \"$winLog\"" notifyInfo "$dir: $winLog"; } @@ -123,11 +127,19 @@ finds () { # sends a desktop-notification with an icon signalling an error notifyError () { - notify-send "$1" --icon=data-warning; + if [[ ! $(commandExists notify-send) ]]; then + echo "ERROR: $1"; + else + notify-send "$1" --icon=data-warning; + fi } # sends a desktop-notification with an icon signalling a simple information notifyInfo () { - notify-send "$1" --icon=preferences-desktop-notification; + if [[ ! $(commandExists notify-send) ]]; then + echo "INFO: $1"; + else + notify-send "$1" --icon=preferences-desktop-notification; + fi }