diff --git a/modules/home/wayland/apps/eww/bar/css/_powermenu.scss b/modules/home/wayland/apps/eww/bar/css/_powermenu.scss index 6bc0eb9..a273114 100644 --- a/modules/home/wayland/apps/eww/bar/css/_powermenu.scss +++ b/modules/home/wayland/apps/eww/bar/css/_powermenu.scss @@ -1,21 +1,23 @@ -.powermenu-box { - padding: 3rem 2.5rem; - margin: 0; +.pm-overlay { + background-color: rgba(0, 0, 0, 0.55); +} - .powermenu-entry { - margin: 0 0.5rem; +.pm-win { + padding: $popup-scale * 10pt; + font-size: $popup-scale * $panel-font-size; +} - .powermenu-button { - @include background-active; - border-radius: 1rem; - transition: 0.3s; - padding: 3.25rem 4rem; +.pm-btn { + @include background-base2; + @include border-radius; + padding: $popup-scale * 20pt $popup-scale * 16pt; + margin: $popup-scale * 6px; - &:hover { background-color: $base03; } - } - } - - .powermenu-icon { - font-size: 4rem; + &:hover { + @include background-active; + .pm-icon, .pm-label { color: $base01; } } } + +.pm-icon { font-size: 2.4em; @include color-body; } +.pm-label { font-size: 0.70em; margin-top: $popup-scale * 5pt; @include color-body; } diff --git a/modules/home/wayland/apps/eww/bar/modules/clock.yuck b/modules/home/wayland/apps/eww/bar/modules/clock.yuck index 02111f6..180a50a 100644 --- a/modules/home/wayland/apps/eww/bar/modules/clock.yuck +++ b/modules/home/wayland/apps/eww/bar/modules/clock.yuck @@ -6,7 +6,7 @@ :onhover "${EWW_CMD} update date_rev=true" :onhoverlost "${EWW_CMD} update date_rev=false" :onclick "(sleep 0.1 && scripts/panel-toggle clock)" - :onrightclick "(sleep 0.1 && eww-open-on-current-screen powermenu --toggle)" + :onrightclick "(sleep 0.1 && scripts/powermenu-toggle)" (box :class "datetime" (overlay diff --git a/modules/home/wayland/apps/eww/bar/scripts/panel-toggle b/modules/home/wayland/apps/eww/bar/scripts/panel-toggle index ea43ce0..e124fd5 100755 --- a/modules/home/wayland/apps/eww/bar/scripts/panel-toggle +++ b/modules/home/wayland/apps/eww/bar/scripts/panel-toggle @@ -1,30 +1,18 @@ #!/usr/bin/env bash PANEL="$1" -# Drop concurrent invocations, but recover from stale locks (dead processes) -LOCK="/tmp/eww_panel_toggle.lock" -if [ -f "$LOCK" ] && kill -0 "$(cat "$LOCK" 2>/dev/null)" 2>/dev/null; then - exit 0 -fi -echo $$ > "$LOCK" -trap 'rm -f "$LOCK"' EXIT +# Atomic lock: flock acquires exclusively or exits immediately. +# Released automatically when the process exits (no trap needed). +exec 9>"/tmp/eww_panel_toggle.lock" +flock -n 9 || exit 0 CURRENT=$(eww get active-panel 2>/dev/null | tr -d '"') -open_popup() { - local screen - screen=$(hyprctl monitors -j 2>/dev/null | jq -r '.[] | select(.focused == true) | .name' | head -n1) - if [ -n "$screen" ]; then - eww open popup --screen "$screen" - else - eww open popup - fi -} - if [ "$CURRENT" = "$PANEL" ]; then eww update active-panel="" eww close popup 2>/dev/null else eww update active-panel="$PANEL" - open_popup + eww close popup 2>/dev/null + eww-open-on-current-screen popup fi diff --git a/modules/home/wayland/apps/eww/bar/scripts/powermenu-toggle b/modules/home/wayland/apps/eww/bar/scripts/powermenu-toggle new file mode 100755 index 0000000..9d31c6f --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/scripts/powermenu-toggle @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +eww close popup 2>/dev/null +eww update active-panel="" +eww-open-on-current-screen powermenu --toggle diff --git a/modules/home/wayland/apps/eww/bar/scripts/unused/brightness b/modules/home/wayland/apps/eww/bar/scripts/unused/brightness deleted file mode 100755 index 6270197..0000000 --- a/modules/home/wayland/apps/eww/bar/scripts/unused/brightness +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -function get_time_ms { - date -u +%s%3N -} - -icons=("󰛩" "󱩒" "󰛨") - -gen_output() { - icon="${icons[$(awk -v n="$(brillo)" 'BEGIN{print int(n/34)}')]}" - prcnt=$(brillo | xargs printf "%.*f\n" "0") - echo '{"percent": '$prcnt', "icon": "'$icon'"}' -} - -if [[ $(brillo 2>/dev/stdout 1>/dev/null | head -n1 | awk '{print $1}') == "No" ]]; then - echo '{"percent": 100, "icon": "󰛨"}' -elif [ "$1" = "" ]; then - # initial - last_time=$(get_time_ms) - gen_output - - udevadm monitor | rg --line-buffered "backlight" | while read -r _; do - current_time=$(get_time_ms) - delta=$((current_time - last_time)) - if [[ $delta -gt 50 ]]; then - gen_output - last_time=$(get_time_ms) - fi - done -fi \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/scripts/unused/flightmode b/modules/home/wayland/apps/eww/bar/scripts/unused/flightmode deleted file mode 100755 index 59e18c5..0000000 --- a/modules/home/wayland/apps/eww/bar/scripts/unused/flightmode +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -icon() { - [ "$STATUS" = "no" ] && echo "󰀞" || echo "󰀝" -} - -toggle() { - if [ "$STATUS" = "no" ]; then - rfkill block all - else - rfkill unblock all - fi -} - -if [ "$1" = "toggle" ]; then - toggle -else - icon - rfkill event | while read -r _; do - STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')" - icon - done -fi \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/scripts/unused/powermode b/modules/home/wayland/apps/eww/bar/scripts/unused/powermode deleted file mode 100755 index 31710ef..0000000 --- a/modules/home/wayland/apps/eww/bar/scripts/unused/powermode +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -icon() { - [ "$STATUS" = "no" ] && echo "󰌪" || echo "󱐋" -} - -toggle() { - if [ "$STATUS" = "no" ]; then - echo "" - else - echo "" - fi -} - -if [ "$1" = "toggle" ]; then - toggle - icon -else - icon -fi \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/scripts/unused/volume b/modules/home/wayland/apps/eww/bar/scripts/unused/volume deleted file mode 100755 index dcafe42..0000000 --- a/modules/home/wayland/apps/eww/bar/scripts/unused/volume +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -function get_time_ms { - date -u +%s%3N -} - -volicons=("󰕿" "󰖀" "󰕾") - -vol() { - wpctl get-volume @DEFAULT_AUDIO_"$1"@ | awk '{print int($2*100)}' -} -ismuted() { - wpctl get-volume @DEFAULT_AUDIO_"$1"@ | rg -qi muted - echo -n $? -} -setvol() { - wpctl set-volume @DEFAULT_AUDIO_"$1"@ "$(awk -v n="$2" 'BEGIN{print (n / 100)}')" -} -setmute() { - wpctl set-mute @DEFAULT_AUDIO_"$1"@ toggle -} - -gen_output() { - percent="$(vol "SINK")" - lvl=$(awk -v n="$percent" 'BEGIN{print int(n/34)}') - ismuted=$(ismuted "SINK") - - if [ "$ismuted" = 1 ]; then - icon="${volicons[$lvl]}" - else - icon="󰝟" - fi - - echo '{"icon": "'$icon'", "percent": '$(vol "SINK")', "microphone": '$(vol "SOURCE")'}' -} - -if [ "$1" = "mute" ]; then - if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then - echo "Can only mute SINK or SOURCE" - exit 1 - fi - setmute "$2" -elif [ "$1" = "setvol" ]; then - if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then - echo "Can only set volume for SINK or SOURCE" - exit 1 - elif [ "$3" -lt 0 ] || [ "$3" -gt 100 ]; then - echo "Volume must be between 0 and 100" - exit 1 - fi - setvol "$2" "$3" -else - last_time=$(get_time_ms) - gen_output - - pw-cli -m 2>/dev/null | rg --line-buffered "PipeWire:Interface:Client" | while read -r event; do - current_time=$(get_time_ms) - delta=$((current_time - last_time)) - if [[ $delta -gt 50 ]]; then - gen_output - last_time=$(get_time_ms) - fi - done -fi diff --git a/modules/home/wayland/apps/eww/bar/windows/powermenu.yuck b/modules/home/wayland/apps/eww/bar/windows/powermenu.yuck index 5d63030..be12694 100644 --- a/modules/home/wayland/apps/eww/bar/windows/powermenu.yuck +++ b/modules/home/wayland/apps/eww/bar/windows/powermenu.yuck @@ -1,45 +1,35 @@ -(defwidget powermenu_entry [label icon onclick] - (box :orientation "v" :space-evenly false :class "powermenu-entry" - (button :class "powermenu-button" :onclick {onclick} - :tooltip "${label}" - (label :class "powermenu-icon" :text {icon}) - ) - ) -) + +(defwidget pm-btn [icon label onclick] + (button :class "pm-btn" :onclick onclick + (box :orientation "v" :space-evenly false :halign "center" :valign "center" + (label :class "pm-icon" :text icon) + (label :class "pm-label" :text label)))) (defwidget powermenu [] - (box :orientation "h" :space-evenly true :valign "center" :halign "center" :class "powermenu-box" - (powermenu_entry :label "Power off" - :icon "󰐥" - :onclick "systemctl poweroff") - (powermenu_entry :label "Reboot" - :icon "󰜉" - :onclick "systemctl reboot") - (powermenu_entry :label "Lock" - :icon "󰍁" - :onclick "sleep 0.1 && gtklock & eww close powermenu &") - - (powermenu_entry :label "Suspend" - :icon "󰤄" - :onclick "sleep 0.1 && gtklock & systemctl suspend & eww close powermenu &") - - (powermenu_entry :label "Sign out" - :icon "󰗼" - :onclick "hyprctl eval \"hl.dispatch(hl.dsp.exit())\"") - - (powermenu_entry :label "Cancel" - :icon "󰅖" - :onclick "eww close powermenu") - ) -) + (box :hexpand true :vexpand true :class "pm-overlay" + (box :halign "center" :valign "center" + (eventbox :class "winevent" + (box :class "wininner pm-win" + (box :orientation "h" :space-evenly true + (pm-btn :icon "󰐥" :label "Power off" + :onclick "systemctl poweroff") + (pm-btn :icon "󰜉" :label "Reboot" + :onclick "systemctl reboot") + (pm-btn :icon "󰍁" :label "Lock" + :onclick "sleep 0.1 && gtklock & eww close powermenu &") + (pm-btn :icon "󰤄" :label "Suspend" + :onclick "sleep 0.1 && gtklock & systemctl suspend & eww close powermenu &") + (pm-btn :icon "󰗼" :label "Sign out" + :onclick "hyprctl eval \"hl.dispatch(hl.dsp.exit())\"") + (pm-btn :icon "󰅖" :label "Cancel" + :onclick "eww close powermenu"))))))) (defwindow powermenu - :monitor 0 - :stacking "overlay" - :geometry (geometry - :anchor "center" - :width "120%" - :height "120%") - :namespace "eww-blur" - (powermenu) -) + :monitor 0 + :stacking "overlay" + :geometry (geometry + :anchor "center" + :width "120%" + :height "120%") + :namespace "eww-blur" + (powermenu)) diff --git a/modules/home/wayland/apps/eww/default.nix b/modules/home/wayland/apps/eww/default.nix index 1028e31..6908464 100755 --- a/modules/home/wayland/apps/eww/default.nix +++ b/modules/home/wayland/apps/eww/default.nix @@ -23,7 +23,8 @@ let scripts = { "scripts/brightness" = mkScript "brightness" ./bar/scripts/brightness [ pkgs.brightnessctl ]; "scripts/nightlight" = mkScript "nightlight" ./bar/scripts/nightlight [ pkgs.wlsunset ]; - "scripts/panel-toggle" = mkScript "panel-toggle" ./bar/scripts/panel-toggle [ pkgs.eww pkgs.jq ]; + "scripts/panel-toggle" = mkScript "panel-toggle" ./bar/scripts/panel-toggle [ pkgs.eww pkgs.util-linux openOnCurrentScreen ]; + "scripts/powermenu-toggle" = mkScript "powermenu-toggle" ./bar/scripts/powermenu-toggle [ pkgs.eww openOnCurrentScreen ]; "scripts/power-save" = mkScript "power-save" ./bar/scripts/power-save [ pkgs.eww ]; "scripts/radio" = mkScript "radio" ./bar/scripts/radio [ pkgs.eww pkgs.jq pkgs.curl pkgs.mpv pkgs.playerctl ]; "scripts/color-pick" = mkScript "color-pick" ./bar/scripts/color-pick [ pkgs.eww pkgs.hyprpicker ]; diff --git a/modules/home/wayland/hyprland/config.nix b/modules/home/wayland/hyprland/config.nix index 1a2c2d2..4e2c8b6 100644 --- a/modules/home/wayland/hyprland/config.nix +++ b/modules/home/wayland/hyprland/config.nix @@ -281,7 +281,7 @@ in { layer_rule = [ { match.namespace = "^eww%-blur$"; blur = true; - ignore_alpha = 0.5; + ignore_alpha = 0.0; }]; bind = [