45 lines
685 B
Plaintext
45 lines
685 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
|
||
|
# if the script is passed --toggle
|
||
|
if [[ "$1" == *toggle* ]]; then
|
||
|
|
||
|
# if caffeine is running kill it
|
||
|
if pgrep caffeine >/dev/null; then
|
||
|
|
||
|
killall caffeine
|
||
|
|
||
|
else # otherwise start it and fork to background
|
||
|
|
||
|
caffeine &>/dev/null &
|
||
|
|
||
|
fi
|
||
|
|
||
|
# exit or get caught in the infinite loop
|
||
|
exit 0
|
||
|
|
||
|
fi
|
||
|
|
||
|
|
||
|
# infinite loop for polybar
|
||
|
while true; do
|
||
|
|
||
|
# caffeine is running
|
||
|
if pgrep caffeine >/dev/null; then
|
||
|
|
||
|
# Change Me
|
||
|
echo "%{F#0000FF}"
|
||
|
|
||
|
else # otherwise it must not be... LOL
|
||
|
|
||
|
# Change Me
|
||
|
echo "%{F#FF0000}"
|
||
|
|
||
|
fi
|
||
|
|
||
|
|
||
|
# sleep interval... Change the responsiveness
|
||
|
sleep 2
|
||
|
|
||
|
done
|