-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdaemons.spell
More file actions
executable file
·39 lines (36 loc) · 911 Bytes
/
daemons.spell
File metadata and controls
executable file
·39 lines (36 loc) · 911 Bytes
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
#!/bin/bash
# Enable/disable my custom daemons
readonly DAEMONS="light,mood_light
battery,use_the_juice
walls,stop_wall"
readonly NUM_DAEMONS="$(echo "$DAEMONS" | wc -l)"
CACHE="/tmp/$LOGNAME"
mkdir -p "$CACHE"
while :; do
i=1
for d in $DAEMONS; do
if [[ -e "$CACHE/${d#*,}" ]]; then
printf "%d) \e[31mOFFLINE\e[0m %s\n" $i "${d%,*}"
else
printf "%d) \e[32mONLINE \e[0m %s\n" $i "${d%,*}"
fi
((i++))
done
unset i
while :; do
read -r -p "${PS3:-#?} " || {
echo
exit
}
[[ "$REPLY" ]] && break
done
if [[ "$REPLY" -le "$NUM_DAEMONS" ]] && [[ "$REPLY" -gt 0 ]]; then
dfile="$(echo "$DAEMONS" | sed -n "${REPLY}p")"
dfile="$CACHE/${dfile#*,}"
if [[ -e "$dfile" ]]; then
rm "$dfile"
else
touch "$dfile"
fi
fi
done