From 37fb63549ec5301a13665480a70cfa2a6ad1c84d Mon Sep 17 00:00:00 2001 From: djairoh Date: Fri, 2 Oct 2026 01:57:43 +0200 Subject: [PATCH] ft: hyprland to home manager --- lib/hypr.nix | 2 +- modules/desktop/hypr-passthrough.nix | 5 +++-- modules/desktop/hypr-shutdown.nix | 9 +++++---- modules/desktop/hypr-workspaces.nix | 3 ++- modules/desktop/hypr-xf86.nix | 6 +++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/hypr.nix b/lib/hypr.nix index cfb088b..194b874 100644 --- a/lib/hypr.nix +++ b/lib/hypr.nix @@ -27,7 +27,7 @@ rec { bindm = keys: dispatcher: desc: bindWith {description = desc; mouse = true;} keys dispatcher; exec = cmd: "hl.dsp.exec_cmd(${str cmd})"; - mulexec = cmds: "function() ${lib.concatMapStringsSep " " (cmd: "hl.dsp.exec_cmd(${str cmd})") cmds} end"; + muldsp = dsps: "function()\n ${lib.concatMapStringsSep "\n " (dsp: "hl.dispatch(${dsp})") dsps}\n end"; pass = window: "hl.dsp.pass({ window = ${str window}})"; submap = name: "hl.dsp.submap(${str name})"; diff --git a/modules/desktop/hypr-passthrough.nix b/modules/desktop/hypr-passthrough.nix index 2b3a0f8..6a2f1d2 100644 --- a/modules/desktop/hypr-passthrough.nix +++ b/modules/desktop/hypr-passthrough.nix @@ -3,10 +3,11 @@ let inherit (hyprLib) bind + makeSubmap + muldsp pass sendShortcut submap - makeSubmap ; makePassthrough = window: binds: @@ -17,7 +18,7 @@ let v = builtins.elemAt mapping 1; d = if builtins.length mapping >= 3 then builtins.elemAt mapping 2 else ""; in - [k (sendShortcut v window) d] + [k (muldsp [(sendShortcut v window) (submap "reset")]) d] ) binds; in customBinds ++ [["ESCAPE" (submap "reset")]]; diff --git a/modules/desktop/hypr-shutdown.nix b/modules/desktop/hypr-shutdown.nix index 44b81da..9ea6a74 100644 --- a/modules/desktop/hypr-shutdown.nix +++ b/modules/desktop/hypr-shutdown.nix @@ -6,6 +6,7 @@ let exec submap makeSubmap + muldsp ; systemModeName = " l e s h r ^s"; @@ -19,10 +20,10 @@ in define_submap = [ (makeSubmap systemModeName [ - ["L" (exec "${exitScript} lock") "Lock the machine"] - ["E" (exec "${exitScript} logout") "Log out"] - ["S" (exec "${exitScript} suspend") "Suspend the machine"] - ["H" (exec "${exitScript} hibernate") "Hibernate the machine"] + ["L" (muldsp [(exec "${exitScript} lock") (submap "reset")]) "Lock the machine"] + ["E" (muldsp [(exec "${exitScript} logout") (submap "reset")]) "Log out"] + ["S" (muldsp [(exec "${exitScript} suspend") (submap "reset")]) "Suspend the machine"] + ["H" (muldsp [(exec "${exitScript} hibernate") (submap "reset")]) "Hibernate the machine"] ["R" (exec "${exitScript} reboot") "Reboot the machine"] ["SHIFT + S" (exec "${exitScript} shutdown") "Power the machine off"] ["ESCAPE" (submap "reset") "Return to default mode"] diff --git a/modules/desktop/hypr-workspaces.nix b/modules/desktop/hypr-workspaces.nix index 63511e7..7e92b4b 100644 --- a/modules/desktop/hypr-workspaces.nix +++ b/modules/desktop/hypr-workspaces.nix @@ -3,6 +3,7 @@ let inherit (hyprLib) bind + muldsp focusWorkspace moveWorkspace submap @@ -29,7 +30,7 @@ in ] ++ builtins.concatLists (builtins.genList (i: let ws = i+10; in [ - [(toString i) (focusWorkspace ws) ""] + [(toString i) (muldsp [(focusWorkspace ws) (submap "reset")]) ""] ["SHIFT + ${toString i}" (moveWorkspace ws false)] ]) 9)))]; diff --git a/modules/desktop/hypr-xf86.nix b/modules/desktop/hypr-xf86.nix index a627d47..cd1b903 100644 --- a/modules/desktop/hypr-xf86.nix +++ b/modules/desktop/hypr-xf86.nix @@ -4,7 +4,7 @@ let inherit (hyprLib) bind exec - mulexec + muldsp ; in { @@ -14,8 +14,8 @@ in (bind "XF86AudioMute" (exec "pactl set-sink-mute @DEFAULT_SINK@ toggle") "Toggle mute using XF86 keys") (bind "XF86AudioMicMute" (exec "pactl set-source-mute @DEFAULT_SOURCE@ toggle ") "Toggle microphone mute using XF86 keys") - (bind "XF86MonBrightnessUp" (mulexec ["brightnessctl set +10%" "~/.config/WMScripts/backlight-notif.sh"]) "Increase screen brightness using XF86 keys") - (bind "XF86MonBrightnessDown" (mulexec ["brightnessctl set 10%-" "~/.config/WMScripts/backlight-notif.sh"]) "Decrease screen brightness using XF86 keys") + (bind "XF86MonBrightnessUp" (muldsp [(exec "brightnessctl set +10%") (exec "~/.config/WMScripts/backlight-notif.sh")]) "Increase screen brightness using XF86 keys") + (bind "XF86MonBrightnessDown" (muldsp [(exec "brightnessctl set 10%-") (exec "~/.config/WMScripts/backlight-notif.sh")]) "Decrease screen brightness using XF86 keys") ]; }