scripts/waybar/waybar-gammastep.sh

74 lines
1.8 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)
2023-01-06 19:41:31 +00:00
RUNNING=0
if [ -e $HOME/.spool/gammastep.status ]; then
RUNNING=`cat $HOME/.spool/gammastep.status`
fi
2022-08-26 05:05:14 +00:00
2022-09-23 22:07:06 +00:00
ACTION=$1
if [[ "$1" == '' ]]; then
2023-01-06 19:41:31 +00:00
ACTION='bar'
2022-09-23 22:07:06 +00:00
fi
if [[ $ACTION == 'bar' ]]; then
2023-01-06 19:41:31 +00:00
:
2022-09-23 22:07:06 +00:00
elif [[ $ACTION == 'toggle' ]]; then
2023-04-09 17:18:09 +00:00
if [ ! -z $PID ]; then
2023-01-06 19:41:31 +00:00
kill -SIGUSR1 $PID
2023-04-09 17:18:09 +00:00
if [[ $RUNNING == 0 ]]; then
echo 1 > $HOME/.spool/gammastep.status
else
echo 0 > $HOME/.spool/gammastep.status
fi
2023-01-06 19:41:31 +00:00
else
echo 'Gammastep is not running'
fi
2022-09-23 22:07:06 +00:00
elif [[ $ACTION == 'start' ]]; then
2023-04-09 17:18:09 +00:00
if [ ! -z $PID ]; then
2023-01-06 19:41:31 +00:00
echo 'Gammastep is already running'
else
2023-05-13 18:24:20 +00:00
$HOME/scripts/distrobox/toolbox/gammastep.pl
2023-01-06 19:41:31 +00:00
fi
2022-09-23 22:07:06 +00:00
elif [[ $ACTION == 'stop' ]]; then
2023-04-09 17:18:09 +00:00
if [ ! -z $PID ]; then
2023-01-06 19:41:31 +00:00
kill $PID
else
echo 'Gammastep is not running'
fi
2022-09-23 22:07:06 +00:00
elif [[ $ACTION == 'enable' ]]; then
2023-04-09 17:18:09 +00:00
if [ ! -z $PID ]; then
if [[ $RUNNING != 0 ]]; then
2023-01-06 19:41:31 +00:00
echo 'Already enabled'
2022-09-23 22:07:06 +00:00
else
2023-01-06 19:41:31 +00:00
kill -SIGUSR1 $PID
2023-04-09 17:18:09 +00:00
echo 1 > $HOME/.spool/gammastep.status
2022-09-23 22:07:06 +00:00
fi
2023-01-06 19:41:31 +00:00
else
echo 'Gammastep is not running'
fi
2022-09-23 22:07:06 +00:00
elif [[ $ACTION == 'disable' ]]; then
2023-04-09 17:18:09 +00:00
if [ ! -z $PID ]; then
2023-01-06 19:41:31 +00:00
if [ $RUNNING ]; then
kill -SIGUSR1 $PID
2023-04-09 17:18:09 +00:00
echo 0 > $HOME/.spool/gammastep.status
2022-09-23 22:07:06 +00:00
else
2023-01-06 19:41:31 +00:00
echo 'Already disabled'
2022-09-23 22:07:06 +00:00
fi
2023-01-06 19:41:31 +00:00
else
echo 'Gammastep in not running'
fi
2022-09-23 22:07:06 +00:00
else
2023-01-06 19:41:31 +00:00
echo "Invalid argument '$ACTION'. Use 'bar', 'toggle', 'start', 'stop', 'enable', 'disable'."
2022-08-26 05:05:14 +00:00
fi
2023-01-06 19:41:31 +00:00
RUNNING=0
if [ -e $HOME/.spool/gammastep.status ]; then
RUNNING=`cat $HOME/.spool/gammastep.status`
fi
2023-04-09 17:18:09 +00:00
if [[ $RUNNING == 0 ]]; then
2023-01-06 19:41:31 +00:00
echo '{"text":"ɣ","icon":"ɣ","tooltip":"Enable Gammastep","class":"disabled"}'
2023-04-09 17:18:09 +00:00
else
echo '{"text":"ɣ","icon":"ɣ","tooltip":"Disable Gammastep","class":"enabled"}'
2022-08-26 05:05:14 +00:00
fi