Launchers are now toggles

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-08-14 12:30:52 +02:00
parent 0846223efd
commit 56341489e8
+20 -6
View File
@@ -6,16 +6,17 @@
}: let }: let
colors = config.lib.stylix.colors; colors = config.lib.stylix.colors;
scripts = import ../waybar/scripts.nix {inherit pkgs config;}; scripts = import ../waybar/scripts.nix {inherit pkgs config;};
border-size = config.theme.border-size;
mkMenu = menu: let mkMenu = menu: let
configFile = pkgs.writeText "config.yaml" ( configFile = pkgs.writeText "config.yaml" (
lib.generators.toYAML {} { lib.generators.toYAML {} {
anchor = "bottom-right"; anchor = "top";
border = "#${colors.base0D}80"; border = "#${colors.base0D}EE";
background = "#${colors.base01}EE"; border_width = border-size;
background = "#${colors.base01}FF";
color = "#${colors.base05}"; color = "#${colors.base05}";
margin_right = 15; margin_top = 0;
margin_bottom = 15;
rows_per_column = 5; rows_per_column = 5;
inherit menu; inherit menu;
@@ -23,8 +24,21 @@
); );
in in
pkgs.writeShellScriptBin "menu" '' pkgs.writeShellScriptBin "menu" ''
# Toggle: if wlr-which-key is already open, closing it is all this run should do.
if ${pkgs.procps}/bin/pkill -x wlr-which-key; then
exit 0
fi
exec ${lib.getExe pkgs.wlr-which-key} ${configFile} exec ${lib.getExe pkgs.wlr-which-key} ${configFile}
''; '';
tofi-drun-toggle = pkgs.writeShellScriptBin "tofi-drun-toggle" ''
# tofi-drun is a distinct process name from the plain "tofi" binary
# used by the emoji/icon/clipboard pickers, so this can't close those.
if ${pkgs.procps}/bin/pkill -x tofi-drun; then
exit 0
fi
exec ${pkgs.tofi}/bin/tofi-drun
'';
in { in {
wayland.windowManager.hyprland.settings = { wayland.windowManager.hyprland.settings = {
"$mod" = "SUPER"; "$mod" = "SUPER";
@@ -121,7 +135,7 @@ in {
# Quick launch # Quick launch
"$mod,RETURN, exec, ${pkgs.ghostty}/bin/ghostty +new-window" # Ghostty (terminal, via daemon D-Bus) "$mod,RETURN, exec, ${pkgs.ghostty}/bin/ghostty +new-window" # Ghostty (terminal, via daemon D-Bus)
"$mod,E, exec, ${pkgs.ghostty}/bin/ghostty +new-window -e elio" # Elio "$mod,E, exec, ${pkgs.ghostty}/bin/ghostty +new-window -e elio" # Elio
"$mod, SPACE, exec, ${pkgs.tofi}/bin/tofi-drun" # Launcher "$mod, SPACE, exec, ${lib.getExe tofi-drun-toggle}" # Launcher (toggle)
"$mod, N, exec, ${pkgs.swaynotificationcenter}/bin/swaync-client -t" # Notification center "$mod, N, exec, ${pkgs.swaynotificationcenter}/bin/swaync-client -t" # Notification center
# Windows # Windows