waybar: add a power menu module

Click the ⏻ glyph on the right edge of the bar; a fuzzel dmenu pops up
with Lock / Logout / Reboot / Shutdown. Lock runs hyprlock, logout
exits Hyprland, the others go through systemctl. Hover state turns the
icon base08 (red) as a soft warning.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
ediblerope 2026-05-12 11:49:44 +01:00
parent af647e2a1e
commit 5caf3d733f

View file

@ -298,7 +298,7 @@
modules-left = [ "hyprland/workspaces" ]; modules-left = [ "hyprland/workspaces" ];
modules-center = [ "clock" ]; modules-center = [ "clock" ];
modules-right = [ "pulseaudio" "network" "tray" ]; modules-right = [ "pulseaudio" "network" "tray" "custom/power" ];
"hyprland/workspaces" = { "hyprland/workspaces" = {
format = "{name}"; format = "{name}";
@ -335,6 +335,21 @@
icon-size = 16; icon-size = 16;
spacing = 8; spacing = 8;
}; };
"custom/power" = {
format = "";
tooltip = false;
on-click = "${pkgs.writeShellScript "power-menu" ''
choice=$(printf "Lock\nLogout\nReboot\nShutdown" \
| ${pkgs.fuzzel}/bin/fuzzel --dmenu --prompt="Power: " --lines=4 --width=12)
case "$choice" in
Lock) ${pkgs.hyprlock}/bin/hyprlock ;;
Logout) hyprctl dispatch exit ;;
Reboot) systemctl reboot ;;
Shutdown) systemctl poweroff ;;
esac
''}";
};
}; };
# Colour tokens (@base00..@base0F) are injected by stylix's waybar # Colour tokens (@base00..@base0F) are injected by stylix's waybar
@ -382,7 +397,8 @@
#pulseaudio, #pulseaudio,
#network, #network,
#tray { #tray,
#custom-power {
padding: 0 10px; padding: 0 10px;
color: @base05; color: @base05;
} }
@ -392,9 +408,17 @@
color: @base03; color: @base03;
} }
#tray { #custom-power:hover {
color: @base08;
}
#custom-power {
margin-right: 6px; margin-right: 6px;
} }
#tray {
margin-right: 0;
}
''; '';
}; };
}; };