From bd18d5972b81391892e04378b2f099c0ce6fdd67 Mon Sep 17 00:00:00 2001 From: Jacoby6000 Date: Tue, 16 Jul 2024 19:48:28 -0500 Subject: [PATCH] Allow applet script to search path relative to the script for cli input themes --- files/applets/bin/appasroot.sh | 21 +++++++++++++-------- files/applets/bin/apps.sh | 21 +++++++++++++-------- files/applets/bin/battery.sh | 21 +++++++++++++-------- files/applets/bin/brightness.sh | 21 +++++++++++++-------- files/applets/bin/mpd.sh | 21 +++++++++++++-------- files/applets/bin/powermenu.sh | 21 +++++++++++++-------- files/applets/bin/quicklinks.sh | 21 +++++++++++++-------- files/applets/bin/screenshot.sh | 21 +++++++++++++-------- files/applets/bin/volume.sh | 21 +++++++++++++-------- 9 files changed, 117 insertions(+), 72 deletions(-) diff --git a/files/applets/bin/appasroot.sh b/files/applets/bin/appasroot.sh index 64d6486..75a799a 100755 --- a/files/applets/bin/appasroot.sh +++ b/files/applets/bin/appasroot.sh @@ -6,19 +6,24 @@ ## Applets : Run Applications as Root # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/apps.sh b/files/applets/bin/apps.sh index 25d34bc..07cb908 100755 --- a/files/applets/bin/apps.sh +++ b/files/applets/bin/apps.sh @@ -6,19 +6,24 @@ ## Applets : Favorite Applications # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/battery.sh b/files/applets/bin/battery.sh index f5deba5..d7fdd7c 100755 --- a/files/applets/bin/battery.sh +++ b/files/applets/bin/battery.sh @@ -6,19 +6,24 @@ ## Applets : Battery # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/brightness.sh b/files/applets/bin/brightness.sh index 62035aa..5fe23d1 100755 --- a/files/applets/bin/brightness.sh +++ b/files/applets/bin/brightness.sh @@ -6,19 +6,24 @@ ## Applets : Brightness # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/mpd.sh b/files/applets/bin/mpd.sh index c7ffd8a..af61fce 100755 --- a/files/applets/bin/mpd.sh +++ b/files/applets/bin/mpd.sh @@ -6,19 +6,24 @@ ## Applets : MPD (music) # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/powermenu.sh b/files/applets/bin/powermenu.sh index 56727a5..5b97fa7 100755 --- a/files/applets/bin/powermenu.sh +++ b/files/applets/bin/powermenu.sh @@ -6,19 +6,24 @@ ## Applets : Power Menu # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/quicklinks.sh b/files/applets/bin/quicklinks.sh index a8a20c6..d469ca8 100755 --- a/files/applets/bin/quicklinks.sh +++ b/files/applets/bin/quicklinks.sh @@ -6,19 +6,24 @@ ## Applets : Quick Links # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/screenshot.sh b/files/applets/bin/screenshot.sh index 7380ade..fd081bd 100755 --- a/files/applets/bin/screenshot.sh +++ b/files/applets/bin/screenshot.sh @@ -6,19 +6,24 @@ ## Applets : Screenshot # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi diff --git a/files/applets/bin/volume.sh b/files/applets/bin/volume.sh index d6bf62e..9b5ccb4 100755 --- a/files/applets/bin/volume.sh +++ b/files/applets/bin/volume.sh @@ -6,19 +6,24 @@ ## Applets : Volume # Import Current Theme -INPUT_THEME=$1 - -if [ -z $INPUT_THEME ]; then - source "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../shared/theme.bash +INPUT_THEME="$1" +SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +if [ -z "$INPUT_THEME" ]; then + source "$SCRIPT_DIR/../shared/theme.bash" theme="$type/$style" elif [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: $0 [theme]" exit 0 else - theme=$INPUT_THEME - if [ ! -d $theme ]; then - echo "Theme not found!" - exit 1 + theme="$INPUT_THEME" + if [ ! -d $theme ]; + # prepend current script path if theme is not found + theme="$SCRIPT_DIR/$theme" + + if [ ! -d "$theme" ]; then + # fail if we still can't find it. + echo "Theme not found!" + exit 1 fi fi