From 12ad9d83d5ec02614e527f50c3e2d755e8fa8cfe Mon Sep 17 00:00:00 2001 From: zephrynis Date: Fri, 31 Jul 2026 10:28:07 +0100 Subject: [PATCH] home: rebind Super+W to Firefox, Super+Shift+W to Firefox (Work) The end-4 dots bind Super+W to $browser, which launch_first_available.sh resolves to Chrome when it is installed. Append an unbind + rebind to hypr/custom/keybinds.lua (sourced after the default) on each activation so Super+W opens Firefox and Super+Shift+W opens the Firefox work profile, re-added after every dots recopy. Chain reloadHyprland after it. Co-Authored-By: Claude Opus 4.8 (1M context) --- home/zephrynis.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/home/zephrynis.nix b/home/zephrynis.nix index ee83c9d..e761b7e 100644 --- a/home/zephrynis.nix +++ b/home/zephrynis.nix @@ -142,10 +142,32 @@ in # sets this to qt6ct) home.sessionVariables.QT_QPA_PLATFORMTHEME = lib.mkForce "kde"; + # Super+W opens Firefox instead of Chrome. The dots' hyprland/keybinds.lua + # binds it to $browser, which launch_first_available.sh resolves to the first + # installed of google-chrome-stable, zen, firefox, ... — so with Chrome + # installed it lands on Chrome. custom/keybinds.lua is sourced after the + # default, so unbind + rebind wins; re-appended after every recopy. + # Super+Shift+W is the "variant" pairing (Shift = variant throughout the dots) + # for the Firefox work profile, matching the firefox-work shim/desktop entry. + home.activation.browserKeybindFirefox = lib.hm.dag.entryAfter [ "hyprlandMonitorLayout" ] '' + hyprCustomKeybinds="$HOME/.config/hypr/custom/keybinds.lua" + if [ -f "$hyprCustomKeybinds" ] && ! grep -q 'App: Firefox' "$hyprCustomKeybinds"; then + cat >> "$hyprCustomKeybinds" << 'EOF' + +-- Super+W -> Firefox (appended by nix-flake, overrides the dots' browser bind) +hl.unbind("SUPER + W") +hl.bind("SUPER + W", hl.dsp.exec_cmd("firefox"), { description = "App: Firefox" }) +-- Super+Shift+W -> Firefox work profile (matches the firefox-work shim/WM class) +hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("firefox -P work --name firefox-work"), { description = "App: Firefox (Work)" }) +EOF + echo "Rebound Super+W to Firefox and Super+Shift+W to Firefox (Work) in hypr/custom/keybinds.lua" + fi + ''; + # The illogical-flake copy step deletes/recreates ~/.config/hypr while # Hyprland is running; its mid-copy reload fails ("cannot open hyprland.lua") # and the error banner sticks. Reload once the configs are back in place. - home.activation.reloadHyprland = lib.hm.dag.entryAfter [ "hyprlandMonitorLayout" ] '' + home.activation.reloadHyprland = lib.hm.dag.entryAfter [ "browserKeybindFirefox" ] '' for instance in /run/user/$(id -u)/hypr/*/; do [ -d "$instance" ] || continue HYPRLAND_INSTANCE_SIGNATURE="$(basename "$instance")" \