improve eww

This commit is contained in:
2026-09-10 19:54:50 +02:00
parent e551d36e1c
commit 7bb27f9373
46 changed files with 1296 additions and 1092 deletions
@@ -1,20 +1,35 @@
#!/usr/bin/env bash
PANEL="$1"
# Toggle a panel of the popup window on the focused monitor.
#
# The popup hosts every panel behind revealers, so switching panels while it
# is open is just a variable update (animated, no scripts restarted). It is
# only closed and re-opened when it has to move to another monitor.
panel=$1
[[ -n $panel ]] || exit 64
# Atomic lock: flock acquires exclusively or exits immediately.
# Released automatically when the process exits (no trap needed).
exec 9>"/tmp/eww_panel_toggle.lock"
# One toggle at a time; the lock dies with this process. fd 9 is closed for
# every eww call so nothing can inherit it.
exec 9>"${XDG_RUNTIME_DIR:-/tmp}/eww-panel-toggle.lock"
flock -n 9 || exit 0
# Every eww call must run with fd 9 closed (9>&-): `eww open` daemonizes and
# would inherit the fd, holding the flock forever and wedging all later toggles.
CURRENT=$(eww get active-panel 2>/dev/null 9>&- | tr -d '"')
ew() { timeout 5 eww "$@" 9>&-; }
if [ "$CURRENT" = "$PANEL" ]; then
eww update active-panel="" 9>&-
eww close popup 2>/dev/null 9>&-
current=$(ew get active-panel 2>/dev/null | tr -d '"')
popup_screen=$(ew get popup-screen 2>/dev/null | tr -d '"')
screen=$(eww-bar focused)
if ew active-windows 2>/dev/null | grep -qx 'popup: popup'; then open=1; else open=0; fi
if ((open)) && [[ $current == "$panel" ]]; then
ew update active-panel=
ew close popup
elif ((open)) && [[ -n $screen && $popup_screen == "$screen" ]]; then
ew update active-panel="$panel"
else
eww update active-panel="$PANEL" 9>&-
eww close popup 2>/dev/null 9>&-
eww-open-on-current-screen popup 9>&-
((open)) && ew close popup
ew update active-panel="$panel" popup-screen="$screen"
if [[ -n $screen ]]; then
ew open popup --screen "$screen"
else
ew open popup
fi
fi