From 4c09537776022a1c69134ab24ed307644136f2e1 Mon Sep 17 00:00:00 2001 From: fabian Date: Wed, 19 Nov 2025 20:54:18 +0100 Subject: [PATCH] - removed debug ouptut - only execute certain code when the accompanying command exists --- home_external/.bash_aliases | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/home_external/.bash_aliases b/home_external/.bash_aliases index 049b310..7ee9e72 100644 --- a/home_external/.bash_aliases +++ b/home_external/.bash_aliases @@ -40,11 +40,6 @@ 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)"; @@ -52,25 +47,18 @@ 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"; @@ -88,7 +76,7 @@ doUpdateFlatpak() { # executes command and notifies upon failure execute() { dir="$(pwd)"; - dir=${dir##*/}; # cut off previous path (/path/to/foo.txt -> foo.txt) + dir=${dir##*/}; if [[ -n "$2" ]]; then errLog=$2; else @@ -112,9 +100,17 @@ 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"; } @@ -127,19 +123,11 @@ finds () { # sends a desktop-notification with an icon signalling an error notifyError () { - if [[ ! $(commandExists notify-send) ]]; then - echo "ERROR: $1"; - else - notify-send "$1" --icon=data-warning; - fi + notify-send "$1" --icon=data-warning; } # sends a desktop-notification with an icon signalling a simple information notifyInfo () { - if [[ ! $(commandExists notify-send) ]]; then - echo "INFO: $1"; - else - notify-send "$1" --icon=preferences-desktop-notification; - fi + notify-send "$1" --icon=preferences-desktop-notification; }