From c7945188176d55fed3bce47882f04a630d972d74 Mon Sep 17 00:00:00 2001 From: SZIMNAU Date: Wed, 5 Nov 2025 14:06:40 +0100 Subject: [PATCH] - added helper method to look up wether a command exists - avoid calling flatpak or notify-send if not installed --- home_external/.bash_aliases | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/home_external/.bash_aliases b/home_external/.bash_aliases index 34f2456..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)"; @@ -52,7 +57,7 @@ rsyncLink() { updateSystem() { - executeAndNotify "doUpdateSystem $1" "system updated" "system update failed" + executeAndNotify "doUpdateSystem $1" "system updated" "system update failed" } @@ -63,6 +68,9 @@ doUpdateSystem() { updateFlatpak() { + if [[ ! $(commandExists flatpak) ]]; then + return 1; + fi noconfirm= if [[ $1 == "-y" ]]; then noconfirm="--assumeyes"; @@ -119,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 }