switch to a nix variable for the hyprland main mod

also adds some function imports cause I forgor xddd
This commit is contained in:
jacekpoz 2024-08-27 16:22:12 +02:00
parent 0bbc352e8f
commit 809a7ab4c5
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -10,8 +10,8 @@
hmCfg = config.home-manager.users.${username};
inherit (builtins) toString;
inherit (lib.attrsets) attrValues mapAttrsToList;
inherit (lib.lists) elem genList map optionals;
inherit (lib.attrsets) attrNames attrValues mapAttrsToList;
inherit (lib.lists) elem flatten genList imap0 map optionals;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption mkOption;
@ -174,9 +174,9 @@ in {
enable = true;
package = hyprland;
plugins = cfg.extraPlugins;
settings = {
"$mainMod" = "SUPER";
settings = let
mod = "SUPER";
in {
monitor = mapAttrsToList (name: m: let
w = toString m.resolution.w;
h = toString m.resolution.h;
@ -328,81 +328,81 @@ in {
map (i: let
key = if i == "10" then "0" else i;
dispatcher = "${optionalString smwPresent "split-"}workspace";
in "$mainMod, ${key}, ${dispatcher}, ${i}"
in "${mod}, ${key}, ${dispatcher}, ${i}"
) (genList (i: toString (i + 1)) 10)
) ++ (
# movetoworkspacesilent
map (i: let
key = if i == "10" then "0" else i;
dispatcher = "${optionalString smwPresent "split-"}movetoworkspacesilent";
in "$mainMod SHIFT, ${key}, ${dispatcher}, ${i}"
in "${mod} SHIFT, ${key}, ${dispatcher}, ${i}"
) (genList (i: toString (i + 1)) 10)
) ++ [
"$mainMod, RETURN, exec, ${if config.poz.programs.foot.server then footclient else foot}"
"$mainMod, Q, killactive"
"$mainMod, F, fullscreen, 0"
"$mainMod, M, fullscreen, 1"
"$mainMod, D, exec, ${pkill} anyrun || ${anyrun}"
"$mainMod, SPACE, togglefloating, active"
"$mainMod SHIFT, C, centerwindow"
"$mainMod CONTROL, R, bringactivetotop"
"$mainMod SHIFT, P, pin"
"$mainMod, W, exec, ${removeSuffix " %U" hmCfg.xdg.desktopEntries.firefox-schizo.exec}"
"$mainMod SHIFT, W, exec, ${removeSuffix " %U" hmCfg.xdg.desktopEntries.firefox-unschizo.exec}"
"${mod}, RETURN, exec, ${if config.poz.programs.foot.server then footclient else foot}"
"${mod}, Q, killactive"
"${mod}, F, fullscreen, 0"
"${mod}, M, fullscreen, 1"
"${mod}, D, exec, ${pkill} anyrun || ${anyrun}"
"${mod}, SPACE, togglefloating, active"
"${mod} SHIFT, C, centerwindow"
"${mod} CONTROL, R, bringactivetotop"
"${mod} SHIFT, P, pin"
"${mod}, W, exec, ${removeSuffix " %U" hmCfg.xdg.desktopEntries.firefox-schizo.exec}"
"${mod} SHIFT, W, exec, ${removeSuffix " %U" hmCfg.xdg.desktopEntries.firefox-unschizo.exec}"
# screenshots
"$mainMod, S, exec, ${grimblast} save area - | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken\""
"$mainMod SHIFT, S, exec, ${grimblast} save area - | ${shadower} | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken (shadower)\""
"$mainMod CONTROL, S, exec, ${grimblast} save area - | ${satty} --early-exit --initial-tool brush --save-after-copy -f - --output-filename \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" && ${notify-send} \"Screenshot taken\""
"$mainMod SHIFT CONTROL, S, exec, ${grimblast} save area - | ${shadower} | ${satty} --early-exit --initial-tool brush --save-after-copy -f - --output-filename \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" && ${notify-send} \"Screenshot taken (shadower)\""
"$mainMod SHIFT, R, exec, ${hyprctl} reload"
"${mod}, S, exec, ${grimblast} save area - | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken\""
"${mod} SHIFT, S, exec, ${grimblast} save area - | ${shadower} | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken (shadower)\""
"${mod} CONTROL, S, exec, ${grimblast} save area - | ${satty} --early-exit --initial-tool brush --save-after-copy -f - --output-filename \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" && ${notify-send} \"Screenshot taken\""
"${mod} SHIFT CONTROL, S, exec, ${grimblast} save area - | ${shadower} | ${satty} --early-exit --initial-tool brush --save-after-copy -f - --output-filename \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" && ${notify-send} \"Screenshot taken (shadower)\""
"${mod} SHIFT, R, exec, ${hyprctl} reload"
(mkIf config.services.asusd.enable ", XF86Launch3, exec, ${asusctl} led-mode -n")
(mkIf config.services.asusd.enable ", XF86Launch4, exec, ${asusctl} profile -n")
# TODO implement touchpad toggle some day maybe
", XF86TouchpadToggle, exec, "
"$mainMod, T, exec, ${grim} -g \"$(${slurp})\" -t ppm - | ${tesseract} -l pol - - | ${wl-copy} && ${notify-send} \"Copied text: \" \"\\\"$(${wl-paste})\\\"\""
"$mainMod, SEMICOLON, exec, quickshell -c powermenu"
"$mainMod, G, togglegroup"
"${mod}, T, exec, ${grim} -g \"$(${slurp})\" -t ppm - | ${tesseract} -l pol - - | ${wl-copy} && ${notify-send} \"Copied text: \" \"\\\"$(${wl-paste})\\\"\""
"${mod}, SEMICOLON, exec, quickshell -c powermenu"
"${mod}, G, togglegroup"
# this sometimes fixes the portal
"$mainMod CONTROL, K, exec, ${systemctl} --user restart xdg-desktop-portal-hyprland"
"$mainMod SHIFT, K, exec, ${hyprctl} kill"
"${mod} CONTROL, K, exec, ${systemctl} --user restart xdg-desktop-portal-hyprland"
"${mod} SHIFT, K, exec, ${hyprctl} kill"
# scratchpad binds
"$mainMod, B, togglespecialworkspace, btop"
(mkIf isAmdGpuPresent "$mainMod, A, togglespecialworkspace, amdgpu_top")
"$mainMod, V, togglespecialworkspace, pipewire"
"$mainMod, N, togglespecialworkspace, nixos"
"${mod}, B, togglespecialworkspace, btop"
(mkIf isAmdGpuPresent "${mod}, A, togglespecialworkspace, amdgpu_top")
"${mod}, V, togglespecialworkspace, pipewire"
"${mod}, N, togglespecialworkspace, nixos"
# rog button on laptop keyboard
(mkIf config.services.asusd.enable ", XF86Launch1, togglespecialworkspace, rog")
(mkIf config.services.asusd.enable "$mainMod, R, togglespecialworkspace, rog")
"$mainMod, X, togglespecialworkspace, keepassxc"
"$mainMod, C, exec, ${loginctl} lock-session"
(mkIf config.services.asusd.enable "${mod}, R, togglespecialworkspace, rog")
"${mod}, X, togglespecialworkspace, keepassxc"
"${mod}, C, exec, ${loginctl} lock-session"
# toggle waybar
"$mainMod CONTROL, B, exec, ${pkill} waybar || ${waybar}"
"$mainMod CONTROL, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor 2"
"$mainMod CONTROL, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor 1"
"$mainMod, Z, exec, ${woomer}"
"${mod} CONTROL, B, exec, ${pkill} waybar || ${waybar}"
"${mod} CONTROL, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor 2"
"${mod} CONTROL, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor 1"
"${mod}, Z, exec, ${woomer}"
# I love Microsoft !!!!!!
"$mainMod ALT CONTROL SHIFT, L, exec, ${xdg-open} https://www.linkedin.com/"
"${mod} ALT CONTROL SHIFT, L, exec, ${xdg-open} https://www.linkedin.com/"
];
# repeat
binde = [
# window focus
"$mainMod, J, movefocus, d"
"$mainMod, K, movefocus, u"
"${mod}, J, movefocus, d"
"${mod}, K, movefocus, u"
# monitor focus
"$mainMod, H, focusmonitor, l"
"$mainMod, L, focusmonitor, r"
"${mod}, H, focusmonitor, l"
"${mod}, L, focusmonitor, r"
# keyboard brightness
(mkIf config.services.asusd.enable ", XF86KbdBrightnessUp, exec, ${asusctl} -n")
(mkIf config.services.asusd.enable ", XF86KbdBrightnessDown, exec, ${asusctl} -p")
"$mainMod SHIFT, G, changegroupactive, f"
"$mainMod CONTROL, G, changegroupactive, b"
"${mod} SHIFT, G, changegroupactive, f"
"${mod} CONTROL, G, changegroupactive, b"
"$mainMod, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${awk} '{print $2 + 0.05}')\""
"$mainMod, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${awk} '{if($2 != 1) {print $2 - 0.05}}')\""
"${mod}, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${awk} '{print $2 + 0.05}')\""
"${mod}, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${awk} '{if($2 != 1) {print $2 - 0.05}}')\""
];
# locked
@ -415,15 +415,15 @@ in {
in [
", XF86AudioMedia, exec, ${play-pause}"
", XF86AudioPlay, exec, ${play-pause}"
"$mainMod, Y, exec, ${play-pause}"
"${mod}, Y, exec, ${play-pause}"
", XF86AudioStop, exec, ${stop}"
"$mainMod, U, exec, ${stop}"
"${mod}, U, exec, ${stop}"
", XF86AudioPrev, exec, ${prev}"
"$mainMod, I, exec, ${prev}"
"${mod}, I, exec, ${prev}"
", XF86AudioNext, exec, ${next}"
"$mainMod, O, exec, ${next}"
"${mod}, O, exec, ${next}"
", XF86AudioMute, exec, ${toggle-mute}"
"$mainMod, P, exec, ${toggle-mute}"
"${mod}, P, exec, ${toggle-mute}"
];
# locked + repeat
@ -435,19 +435,19 @@ in {
in [
# TODO integrate the scripts from https://codeberg.org/jacekpoz/dotconfig/src/branch/master/Scripts
", XF86MonBrightnessUp, exec, ${brightness_up}"
"$mainMod SHIFT, Z, exec, ${brightness_up}"
"${mod} SHIFT, Z, exec, ${brightness_up}"
", XF86MonBrightnessDown, exec, ${brightness_down}"
"$mainMod SHIFT, X, exec, ${brightness_down}"
"${mod} SHIFT, X, exec, ${brightness_down}"
", XF86AudioRaiseVolume, exec, ${volume_up}"
"$mainMod SHIFT, C, exec, ${volume_up}"
"${mod} SHIFT, C, exec, ${volume_up}"
", XF86AudioLowerVolume, exec, ${volume_down}"
"$mainMod SHIFT, V, exec, ${volume_down}"
"${mod} SHIFT, V, exec, ${volume_down}"
];
# mouse
bindm = [
"$mainMod, mouse:272, movewindow"
"$mainMod, mouse:273, resizewindow"
"${mod}, mouse:272, movewindow"
"${mod}, mouse:273, resizewindow"
];
binds = {