scripts/waybar/waybar-gammastep.sh

67 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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