26 lines
440 B
Bash
Executable File
26 lines
440 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
on=""
|
|
off=""
|
|
|
|
# if the script is passed --toggle
|
|
if [[ "$1" ]]; then
|
|
if [[ "$1" == *toggle* ]] && [[ "$(pidof caffeine)" ]]; then
|
|
killall caffeine
|
|
elif [[ "$1" == *toggle* ]]; then
|
|
caffeine &
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
|
|
while true; do
|
|
# caffeine is running
|
|
if [[ "$(pidof caffeine)" ]]; then
|
|
echo "%{F#0000FF}$on"
|
|
else
|
|
echo "%{F#FF0000}$off"
|
|
fi
|
|
sleep 2
|
|
done
|