This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/home/bin/toggle-caffeine

45 lines
685 B
Bash
Executable File

#!/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