From d58b62f69edcf4b8876117b597ca091918e2deaa Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Mon, 9 Dec 2024 00:53:50 +0100 Subject: [PATCH] feat(waybar): add power submenu to options menu --- home/shell.nix | 3 +-- home/sway/sway.nix | 20 ++++++++++++++++++-- home/sway/waybar/default.nix | 1 - 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/home/shell.nix b/home/shell.nix index cccccef..5761054 100644 --- a/home/shell.nix +++ b/home/shell.nix @@ -13,11 +13,10 @@ let # other stuff xclip = "xclip -selection c"; - hibernate = "systemctl hibernate"; open = "xdg-open"; gloww = "glow README.md"; - logout = "exec ${pkgs.systemd}/bin/loginctl terminate-user $USER && ${pkgs.sway}/bin/swaymsg mode default"; + logout = "exec ${pkgs.systemd}/bin/loginctl terminate-user $USER"; # wireguard wgu = "systemctl start wg-quick-wg0"; diff --git a/home/sway/sway.nix b/home/sway/sway.nix index 6c6c954..f846276 100644 --- a/home/sway/sway.nix +++ b/home/sway/sway.nix @@ -8,7 +8,8 @@ }; cfg = config.wayland.windowManager.sway.config; modeScreenshot = "󰄄 (r) region (s) screen"; - modeOptions = "󰄄 (s) sound (d) displays (n) network (b) bluetooth"; + modeOptions = "(s) sound (d) displays (n) network (b) bluetooth (p) power"; + modeShutdown = "(h) hibernate (l) lock (e) logout (r) reboot (u) suspend (s) shutdown"; colors = { text = "#cccccc"; indicator = "#cccccc"; @@ -156,16 +157,19 @@ "${cfg.modifier}+f" = "fullscreen toggle"; # screen lock - "${cfg.modifier}+Shift+Space" = "exec ${pkgs.swaylock}/bin/swaylock && ${pkgs.sway}/bin/swaymsg mode default"; + "${cfg.modifier}+p" = "exec ${pkgs.swaylock}/bin/swaylock"; # Screenshot mode "Print" = "mode \"${modeScreenshot}\""; "${cfg.modifier}+Shift+s" = "mode \"${modeScreenshot}\""; + # Options mode "${cfg.modifier}+o" = "mode \"${modeOptions}\""; + # Multimedia Keys "XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; + "${cfg.modifier}+m" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; "XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; "--locked XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; "--locked XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%"; @@ -189,6 +193,18 @@ "b" = "exec ${pkgs.sway}/bin/swaymsg mode default && ${pkgs.alacritty}/bin/alacritty --class floating_shell -o window.dimensions.columns=164 -o window.dimensions.lines=25 -e ${pkgs.bluetuith}/bin/bluetuith"; "s" = "exec ${pkgs.sway}/bin/swaymsg mode default && ${pkgs.swayfx}/bin/swaymsg exec \"${pkgs.alacritty}/bin/alacritty --class floating_shell -o window.dimensions.columns=82 -o window.dimensions.lines=25 -e ${pkgs.pulsemixer}/bin/pulsemixer\""; "n" = "exec ${pkgs.sway}/bin/swaymsg mode default && ${pkgs.alacritty}/bin/alacritty --class floating_shell -o window.dimensions.columns=82 -o window.dimensions.lines=25 -e ${pkgs.networkmanager}/bin/nmtui connect"; + "p" = "mode \"${modeShutdown}\""; + "${cfg.modifier}+o" = "mode default"; + Escape = "mode default"; + Return = "mode default"; + }; + "${modeShutdown}" = { + "h" = "exec ${pkgs.systemd}/bin/systemctl hibernate && ${pkgs.swayfx}/bin/swaymsg mode default"; + "l" = "exec ${pkgs.swaylock}/bin/swaylock && ${pkgs.swayfx}/bin/swaymsg mode default"; + "e" = "exec ${pkgs.systemd}/bin/loginctl terminate-user $USER && ${pkgs.swayfx}/bin/swaymsg mode default"; + "r" = "exec ${pkgs.systemd}/bin/systemctl reboot && ${pkgs.swayfx}/bin/swaymsg mode default"; + "u" = "exec ${pkgs.systemd}/bin/systemctl suspend && ${pkgs.swayfx}/bin/swaymsg mode default"; + "s" = "exec ${pkgs.systemd}/bin/systemctl poweroff && ${pkgs.swayfx}/bin/swaymsg mode default"; "${cfg.modifier}+o" = "mode default"; Escape = "mode default"; Return = "mode default"; diff --git a/home/sway/waybar/default.nix b/home/sway/waybar/default.nix index 29a4c91..653d614 100644 --- a/home/sway/waybar/default.nix +++ b/home/sway/waybar/default.nix @@ -143,7 +143,6 @@ tooltip = false; scroll-step = 0; # disables scroll format-muted = "VOL: MUTE"; - on-click = "${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; }; bluetooth = { format = "BLUE: on";