From 96112aa68f032de3c98764edc4e1a3a9deda5c40 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Tue, 8 Sep 2026 13:41:18 +0100 Subject: [PATCH] feat(eww): spawn a tray-only waybar with the panel Nothing else hosts StatusNotifierItem here, so tray icons had nowhere to go. Rather than run waybar permanently, the panel toggle starts a tray-only instance and every close path kills it again. Its config lives in ~/.config/waybar-tray so it can't collide with a real waybar setup later. The panel layer also gets xray so the blur samples the wallpaper rather than the windows under it. --- home/common/programs/hyprland/default.nix | 2 +- home/common/programs/hyprland/eww/default.nix | 52 ++++++++++++++++++- .../hyprland/eww/scripts/eww-panel.sh | 9 ++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/home/common/programs/hyprland/default.nix b/home/common/programs/hyprland/default.nix index 3943cb0..8d7f435 100644 --- a/home/common/programs/hyprland/default.nix +++ b/home/common/programs/hyprland/default.nix @@ -264,7 +264,7 @@ in end) -- layer rules - hl.layer_rule({ match = { namespace = "eww-panel" }, blur = true, ignore_alpha = 0.5 }) + hl.layer_rule({ match = { namespace = "eww-panel" }, blur = true, xray = true, ignore_alpha = 0.5 }) -- workspace rules hl.workspace_rule({ workspace = "w[t1]", gaps_out = 0, gaps_in = 0 }) -- no gaps when only window diff --git a/home/common/programs/hyprland/eww/default.nix b/home/common/programs/hyprland/eww/default.nix index 7e19f7a..d4c4e31 100644 --- a/home/common/programs/hyprland/eww/default.nix +++ b/home/common/programs/hyprland/eww/default.nix @@ -45,6 +45,9 @@ let panelToggle = mkScript "eww-panel" [ config.programs.eww.package pkgs.jq + pkgs.waybar + pkgs.procps + pkgs.util-linux inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland ]; @@ -53,10 +56,18 @@ let wpctl = "${pkgs.wireplumber}/bin/wpctl"; wpaperctl = "${pkgs.wpaperd}/bin/wpaperctl"; + # No StatusNotifierItem host runs otherwise (no waybar, no snixembed) — spawn + # a tray-only waybar instance alongside the panel instead of running one + # permanently. Its own config lives outside ~/.config/waybar so it can't + # collide with a "real" waybar setup later. + trayConfigPath = "${config.home.homeDirectory}/.config/waybar-tray/config"; + trayStylePath = "${config.home.homeDirectory}/.config/waybar-tray/style.css"; + killTray = "${pkgs.procps}/bin/pkill -f 'waybar -c ${trayConfigPath}' || true"; + # setsid, and before the close rather than after it: eww kills the onclick # handler's process group when the window it came from goes away, so a bare # `close panel; cmd` never reaches cmd. - act = cmd: "${pkgs.util-linux}/bin/setsid --fork ${cmd}; ${eww} close panel"; + act = cmd: "${pkgs.util-linux}/bin/setsid --fork ${cmd}; ${eww} close panel; ${killTray}"; in { home.packages = [ @@ -64,6 +75,45 @@ in pkgs.waypaper ]; + xdg.configFile = { + "waybar-tray/config".text = builtins.toJSON { + layer = "top"; + position = "top"; + height = builtins.ceil (28 * cfg.panelScale); + "margin-top" = builtins.ceil (10 * cfg.panelScale); + "margin-right" = builtins.ceil (14 * cfg.panelScale); + "modules-left" = [ ]; + "modules-center" = [ ]; + "modules-right" = [ "tray" ]; + tray = { + "icon-size" = builtins.ceil (20 * cfg.panelScale); + spacing = builtins.ceil (10 * cfg.panelScale); + }; + }; + + "waybar-tray/style.css".text = '' + * { + font-family: "FiraCode Nerd Font", monospace; + } + + window#waybar { + background-color: transparent; + } + + #tray { + background-color: rgba(59, 66, 82, 0.72); + border: ${px 1} solid #4c566a; + border-radius: ${px 14}; + padding: 0 ${px 10}; + } + + #tray > .needs-attention { + background-color: #bf616a; + border-radius: ${px 8}; + } + ''; + }; + programs.eww = { enable = true; diff --git a/home/common/programs/hyprland/eww/scripts/eww-panel.sh b/home/common/programs/hyprland/eww/scripts/eww-panel.sh index 37ecaf7..bbe885b 100644 --- a/home/common/programs/hyprland/eww/scripts/eww-panel.sh +++ b/home/common/programs/hyprland/eww/scripts/eww-panel.sh @@ -2,10 +2,19 @@ # this: it ignores --screen when the window is already open elsewhere, so the # panel would stay stuck on the monitor it first appeared on. +tray_config="$HOME/.config/waybar-tray/config" +tray_style="$HOME/.config/waybar-tray/style.css" + if eww active-windows | grep -q '^panel'; then + pkill -f "waybar -c $tray_config" || true exec eww close panel fi +# In case a previous instance was left running (e.g. panel closed by some +# path other than this script or the dashboard's `act` helper). +pkill -f "waybar -c $tray_config" 2>/dev/null || true +setsid --fork waybar -c "$tray_config" -s "$tray_style" >/dev/null 2>&1 + screen=$(hyprctl -j monitors | jq -r 'map(select(.focused))[0].id // 0') exec eww open panel --screen "$screen"