fix freeze eww
This commit is contained in:
@@ -39,6 +39,18 @@ detach() {
|
||||
systemd-run --user --collect --quiet "${unit[@]}" -- "$cmd" "$@"
|
||||
}
|
||||
|
||||
# eww kills a click handler that has not returned within the widget's
|
||||
# :timeout (200 ms) — less than the eww client calls most handlers make
|
||||
# (~50 ms each), let alone bluetoothctl or a station list fetch. Re-run
|
||||
# this script detached and return at once. Call it with the original
|
||||
# arguments, before anything with side effects.
|
||||
# detach_self "$@"
|
||||
detach_self() {
|
||||
[[ -n ${EWW_DETACHED-} ]] && return 0
|
||||
EWW_DETACHED=1 setsid -f "$0" "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Event multiplexer for listener scripts. Producers run in the background
|
||||
# and write one line per event into a fifo; the main loop re-evaluates the
|
||||
# state on every event, coalescing bursts into a single refresh.
|
||||
|
||||
@@ -5,6 +5,7 @@ active() { rfkill list wifi 2>/dev/null | grep -q "Soft blocked: yes"; }
|
||||
case ${1:-} in
|
||||
status) active && echo true || echo false ;;
|
||||
*)
|
||||
detach_self "$@"
|
||||
if active; then
|
||||
rfkill unblock all
|
||||
state=false
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
case ${1:-} in
|
||||
status) dunstctl is-paused ;;
|
||||
*)
|
||||
detach_self "$@"
|
||||
dunstctl set-paused toggle
|
||||
state=$(dunstctl is-paused)
|
||||
eww update do-not-disturb="$state" 2>/dev/null
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Connect or disconnect the bluetooth device with MAC $1.
|
||||
mac=$1
|
||||
[[ -n $mac ]] || exit 64
|
||||
detach_self "$@"
|
||||
if bluetoothctl info "$mac" 2>/dev/null | grep -q "Connected: yes"; then
|
||||
bluetoothctl disconnect "$mac"
|
||||
else
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# Needs the polkit rule from modules/nixos/system/network/wireguard.
|
||||
name=$1
|
||||
[[ -n $name ]] || exit 64
|
||||
detach_self "$@"
|
||||
if [[ -d /sys/class/net/$name ]]; then
|
||||
systemctl stop "wireguard-$name.service"
|
||||
else
|
||||
|
||||
@@ -8,6 +8,7 @@ active() { systemctl --user is-active --quiet "$unit" || pgrep -x wlsunset >/dev
|
||||
case ${1:-} in
|
||||
status) active && echo true || echo false ;;
|
||||
*)
|
||||
detach_self "$@"
|
||||
if active; then
|
||||
systemctl --user stop "$unit" 2>/dev/null
|
||||
pkill -x wlsunset
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# reply can never spawn a second daemon).
|
||||
panel=$1
|
||||
[[ -n $panel ]] || exit 64
|
||||
detach_self "$@"
|
||||
|
||||
# One toggle at a time; the lock dies with this process. fd 9 is closed for
|
||||
# every eww call so nothing can inherit it.
|
||||
|
||||
@@ -5,6 +5,7 @@ active() { [[ $(powerprofilesctl get 2>/dev/null) == power-saver ]]; }
|
||||
case ${1:-} in
|
||||
status) active && echo true || echo false ;;
|
||||
*)
|
||||
detach_self "$@"
|
||||
if active; then
|
||||
powerprofilesctl set balanced 2>/dev/null
|
||||
state=false
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Toggle the full-screen power menu on the focused monitor. The open's exit
|
||||
# status is ignored: it exceeds the client's 100 ms reply deadline.
|
||||
detach_self "$@"
|
||||
eww close popup 2>/dev/null
|
||||
eww update active-panel= 2>/dev/null
|
||||
screen=$(eww-bar focused)
|
||||
|
||||
@@ -216,10 +216,10 @@ status_loop() {
|
||||
}
|
||||
|
||||
case ${1:-} in
|
||||
start) start "$2" ;;
|
||||
stop) stop ;;
|
||||
toggle) if playing; then stop; else start "$(current_id)"; fi ;;
|
||||
vol) set_volume "$2" ;;
|
||||
mute) toggle_mute ;;
|
||||
start) detach_self "$@"; start "$2" ;;
|
||||
stop) detach_self "$@"; stop ;;
|
||||
toggle) detach_self "$@"; if playing; then stop; else start "$(current_id)"; fi ;;
|
||||
vol) detach_self "$@"; set_volume "$2" ;;
|
||||
mute) detach_self "$@"; toggle_mute ;;
|
||||
*) status_loop ;;
|
||||
esac
|
||||
|
||||
@@ -8,6 +8,7 @@ active() { hyprctl getoption decoration:screen_shader 2>/dev/null | grep -qF "$s
|
||||
case ${1:-} in
|
||||
status) active && echo true || echo false ;;
|
||||
*)
|
||||
detach_self "$@"
|
||||
if active; then
|
||||
hyprctl eval 'hl.config({ decoration = { screen_shader = "" } })' >/dev/null
|
||||
hyprctl eval 'hl.config({ render = { use_fp16 = 2 } })' >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user