improve eww
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
case "$1" in
|
||||
status)
|
||||
pgrep -x wlsunset >/dev/null 2>&1 && echo true || echo false
|
||||
;;
|
||||
# Toggle wlsunset. It runs as the transient user unit eww-nightlight, so it
|
||||
# survives eww restarts and can be stopped by name.
|
||||
unit=eww-nightlight
|
||||
|
||||
active() { systemctl --user is-active --quiet "$unit" || pgrep -x wlsunset >/dev/null; }
|
||||
|
||||
case ${1:-} in
|
||||
status) active && echo true || echo false ;;
|
||||
*)
|
||||
if pgrep -x wlsunset >/dev/null 2>&1; then
|
||||
pkill -x wlsunset && echo false
|
||||
if active; then
|
||||
systemctl --user stop "$unit" 2>/dev/null
|
||||
pkill -x wlsunset
|
||||
state=false
|
||||
else
|
||||
wlsunset -T 4500 -t 3200 & echo true
|
||||
detach -u "$unit" wlsunset -T 4500 -t 3200
|
||||
state=true
|
||||
fi
|
||||
eww update night-light="$state" 2>/dev/null
|
||||
echo "$state"
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user