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
|
2024-03-08 19:11:04 +00:00
|
|
|
|
if [ -e $HOME/.local/state/gammastep.status ]; then
|
|
|
|
|
RUNNING=`cat $HOME/.local/state/gammastep.status`
|
2023-01-06 19:41:31 +00:00
|
|
|
|
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
|
2024-03-08 19:11:04 +00:00
|
|
|
|
echo 1 > $HOME/.local/state/gammastep.status
|
2023-04-09 17:18:09 +00:00
|
|
|
|
else
|
2024-03-08 19:11:04 +00:00
|
|
|
|
echo 0 > $HOME/.local/state/gammastep.status
|
2023-04-09 17:18:09 +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 == '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
|
2024-03-08 19:11:04 +00:00
|
|
|
|
echo 1 > $HOME/.local/state/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
|
2024-03-08 19:11:04 +00:00
|
|
|
|
echo 0 > $HOME/.local/state/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
|
2024-03-08 19:11:04 +00:00
|
|
|
|
if [ -e $HOME/.local/state/gammastep.status ]; then
|
|
|
|
|
RUNNING=`cat $HOME/.local/state/gammastep.status`
|
2023-01-06 19:41:31 +00:00
|
|
|
|
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
|