-
Notifications
You must be signed in to change notification settings - Fork 0
/
applet
executable file
·68 lines (62 loc) · 2.31 KB
/
applet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash
#******************************************************************************
#
# * File: rofi-applets/applet
#
# * Author: Umut Sevdi
# * Created: 08/27/22
# * Description: Command line interface to run Rofi Applets
# * @require rofi
#*****************************************************************************
# Set to default path if applet path is not defined
[ "$ROFI_APPLETS_PATH" = "" ] && ROFI_APPLETS_PATH=$HOME/.dotfiles/rofi-applets/
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()
{
# Display Help
echo "applet.sh - Applet Launcher Interface"
echo "──────────────────────────────────────────────"
echo "Command line interface to run Rofi Applets"
echo
echo "Syntax: [-r]"
echo "Options:"
echo "┌────────────────────────────────────────────┐"
echo "│ -h/--help Prints this menu. │"
echo "│ -r/--run \$app Runs selected applet │"
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}/applets/$app/launch.sh 2>/dev/null
}
if [[ "$#" -eq 0 ]]; then
Help
exit
fi
for arg in $@;do
if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
Help
exit
elif [ "$run" = true ]; then
app=$arg
case "$options" in
*$app*)
Run
exit
;;
esac
echo "error: Applet was not found." 1>&2
elif [ "$arg" = "-r" ] || [ "$arg" = "--run" ]; then
run=true
else
echo -e "Error: Invalid arguments" 1>&2
exit
fi
done