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

22 lines
401 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
on=""
off=""
# if the script is passed --toggle
if [[ $1 == *toggle* ]] && pgrep caffeine &>/dev/null; then
killall caffeine && exit 0
elif [[ $1 == *toggle* ]]; then
caffeine && exit 0
fi
while true; do
# caffeine is running
if pgrep caffeine &>/dev/null; then
echo "%{F#0000FF}$on"
2017-12-02 01:06:11 -06:00
else
echo "%{F#FF0000}$off"
fi
sleep 2
done