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:
parent
af647e2a1e
commit
5caf3d733f
1 changed files with 27 additions and 3 deletions
|
|
@ -298,7 +298,7 @@
|
|||
|
||||
modules-left = [ "hyprland/workspaces" ];
|
||||
modules-center = [ "clock" ];
|
||||
modules-right = [ "pulseaudio" "network" "tray" ];
|
||||
modules-right = [ "pulseaudio" "network" "tray" "custom/power" ];
|
||||
|
||||
"hyprland/workspaces" = {
|
||||
format = "{name}";
|
||||
|
|
@ -335,6 +335,21 @@
|
|||
icon-size = 16;
|
||||
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
|
||||
|
|
@ -382,7 +397,8 @@
|
|||
|
||||
#pulseaudio,
|
||||
#network,
|
||||
#tray {
|
||||
#tray,
|
||||
#custom-power {
|
||||
padding: 0 10px;
|
||||
color: @base05;
|
||||
}
|
||||
|
|
@ -392,9 +408,17 @@
|
|||
color: @base03;
|
||||
}
|
||||
|
||||
#tray {
|
||||
#custom-power:hover {
|
||||
color: @base08;
|
||||
}
|
||||
|
||||
#custom-power {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
#tray {
|
||||
margin-right: 0;
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue