From 27318f674e599a76d17f65ca209216760fbdff78 Mon Sep 17 00:00:00 2001 From: Umut Sevdi Date: Sun, 28 Aug 2022 00:00:19 +0300 Subject: [PATCH] Applet CLI --- applet_cli.sh => applet | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) rename applet_cli.sh => applet (70%) diff --git a/applet_cli.sh b/applet similarity index 70% rename from applet_cli.sh rename to applet index fafddd0..f1f4ab9 100755 --- a/applet_cli.sh +++ b/applet @@ -5,8 +5,9 @@ # Set to default path if applet path is not defined [ "$ROFI_APPLETS_PATH" = "" ] && ROFI_APPLETS_PATH=$HOME/.dotfiles/applets/ -options=`ls -d $ROFI_APPLETS_PATH/*/ | sed "s#$ROFI_APPLETS_PATH##g" | tr "/" " "` -[ "$options" = "" ] && echo "error: No applet were found at $ROFI_APPLETS_PATH directory.\nEither move applets to the $ROFI_APPLETS_PATH or define \$ROFI_APPLETS_PATH at .bashrc" 1>&2 +options=`ls -d ${ROFI_APPLETS_PATH}/applets/*/ | sed "s#${ROFI_APPLETS_PATH}/applets##g" | tr "/" " "` +[ "$options" = "" ] && echo -e "error: No applet were found at $ROFI_APPLETS_PATH directory. +Either move applets to the $ROFI_APPLETS_PATH or define \$ROFI_APPLETS_PATH at .bashrc" 1>&2 Help() @@ -22,14 +23,16 @@ Help() echo "│ -h/--help Prints this menu. │" echo "│ -r/--run \$app Runs selected applet │" echo "└────────────────────────────────────────────┘" - echo " Applets:" - [ "$options" = "" ] && echo "error: No applet were found at $ROFI_APPLETS_PATH directory.\nEither move applets to the $ROFI_APPLETS_PATH or define \$ROFI_APPLETS_PATH at .bashrc" 1>&2 || " `echo $options`" - echo + echo " Available Applets:" + [ "$options" = "" ] && echo -e " error: No applet were found at $ROFI_APPLETS_PATH directory. +Either move applets to the $ROFI_APPLETS_PATH or define \$ROFI_APPLETS_PATH at .bashrc" 1>&2 \ +|| echo "- `echo $options | sed 's/ /\n- /g'`" +echo } Run() { - sh $ROFI_APPLETS_PATH/$app/launch.sh 2>/dev/null + sh ${ROFI_APPLETS_PATH}/applets/$app/launch.sh 2>/dev/null } if [[ "$#" -eq 0 ]]; then