More robust gammastep applet

This commit is contained in:
John Mertz 2022-09-23 18:07:06 -04:00
parent 5cfbde8fdc
commit 4c35268b8f
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
1 changed files with 48 additions and 7 deletions

View File

@ -1,18 +1,59 @@
#!/bin/bash #!/bin/bash
RUNNING=$(pgrep gammastep) PID=$(pgrep gammastep)
RUNNING=`cat $HOME/.spool/gammastep.status`
if [[ $1 == 'toggle' ]]; then ACTION=$1
echo "toggling" if [[ "$1" == '' ]]; then
if [ "$RUNNING" ]; then ACTION='bar'
kill -9 $RUNNING 2&>1 /dev/null fi
echo "$ACTION" >&2
if [[ $ACTION == 'bar' ]]; then
:
elif [[ $ACTION == 'toggle' ]]; then
if [ "$PID" ]; then
kill -SIGUSR1 $PID
else
echo 'Gammastep is not running'
fi
elif [[ $ACTION == 'start' ]]; then
if [ "$PID" ]; then
echo 'Gammastep is already running'
else else
$HOME/scripts/sway/gammastep.pl $HOME/scripts/sway/gammastep.pl
fi fi
RUNNING=$(pgrep gammastep) elif [[ $ACTION == 'stop' ]]; then
if [ "$PID" ]; then
kill $PID
else
echo 'Gammastep is not running'
fi
elif [[ $ACTION == 'enable' ]]; then
if [ $PID ]; then
if [ $RUNNING ]; then
echo 'Already enabled'
else
kill -SIGUSR1 $PID
fi
else
echo 'Gammastep is not running'
fi
elif [[ $ACTION == 'disable' ]]; then
if [ $PID ]; then
if [ $RUNNING ]; then
kill -SIGUSR1 $PID
else
echo 'Already disabled'
fi
else
echo 'Gammastep in not running'
fi
else
echo "Invalid argument '$ACTION'. Use 'bar', 'toggle', 'start', 'stop', 'enable', 'disable'."
fi fi
RUNNING=`cat $HOME/.spool/gammastep.status`
if [ "$RUNNING" ]; then if [ "$RUNNING" ]; then
echo '{"text":"ɣ","icon":"ɣ","tooltip":"Disable Gammastep","class":"enabled"}' echo '{"text":"ɣ","icon":"ɣ","tooltip":"Disable Gammastep","class":"enabled"}'
else else