scripts/waybar/waybar-gammastep.sh

62 lines
1.7 KiB
Bash
Raw Normal View History

2022-08-26 05:05:14 +00:00
#!/bin/bash
2022-09-23 22:07:06 +00:00
PID=$(pgrep gammastep)
RUNNING=`cat $HOME/.spool/gammastep.status`
2022-08-26 05:05:14 +00:00
2022-09-23 22:07:06 +00:00
ACTION=$1
if [[ "$1" == '' ]]; then
ACTION='bar'
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'
2022-08-26 05:05:14 +00:00
else
$HOME/scripts/sway/gammastep.pl
fi
2022-09-23 22:07:06 +00:00
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'."
2022-08-26 05:05:14 +00:00
fi
2022-09-23 22:07:06 +00:00
RUNNING=`cat $HOME/.spool/gammastep.status`
2022-08-26 05:05:14 +00:00
if [ "$RUNNING" ]; then
echo '{"text":"ɣ","icon":"ɣ","tooltip":"Disable Gammastep","class":"enabled"}'
else
echo '{"text":"ɣ","icon":"ɣ","tooltip":"Enable Gammastep","class":"disabled"}'
fi