#!/bin/sh start () { wlsunset -l "59.8" -L "30.2" -t "3000" -T "6500" & } stop () { pkill -x wlsunset } rotate () { pkill -x -SIGUSR1 wlsunset } update_waybar () { pkill -x -SIGRTMIN+10 waybar } is_active () { pkill -x -0 wlsunset } has_wlsunset () { command -v wlsunset >/dev/null } case "$1" in 'start') start update_waybar ;; 'stop') stop update_waybar ;; 'toggle') is_active && stop || start update_waybar ;; 'rotate') rotate update_waybar ;; 'check') has_wlsunset exit $? ;; esac if is_active; then alt="on" tooltip="Stop/rotate wlsunset" else alt="off" tooltip="Start wlsunset" fi printf '{"alt":"%s","tooltip":"%s"}\n' "$alt" "$tooltip"