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