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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user