land.nix: change workspace management and keybinds to maps

This commit is contained in:
Charlie Root 2024-08-28 12:46:27 +02:00
commit 4230d5533c

View file

@ -14,8 +14,8 @@
(inputs'.split-monitor-workspaces.packages) (inputs'.split-monitor-workspaces.packages)
split-monitor-workspaces split-monitor-workspaces
; ;
inherit (lib) flatten mkIf mkDefault mapAttrsToList; inherit (lib) imap0 flatten optionalString mkIf mkDefault mapAttrsToList;
inherit (builtins) toString; inherit (builtins) map genList attrNames toString;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.hyprland = { programs.hyprland = {
@ -83,65 +83,42 @@ in {
) )
monitors; monitors;
workspace = flatten () # INFO: This is a custom function to map all of my monitors to workspaces.
# Since I use split-monitor-workspaces, I map 10 workspaces to each monitor
# Workspace config # and set the first one to be the default one.
workspace = [ # To be able to use this for a varying amount of monitors we do some nasty trickery:
"1,monitor:eDP-1, default:true" workspace =
"2,monitor:eDP-1" # We're creating several lists of workspace assignments, one for each monitor,
"3,monitor:eDP-1" # and have to merge them into one big list.
"4,monitor:eDP-1" (flatten
"5,monitor:eDP-1" # We then use imap0 insted of map because imap0 starts indexing at zero as oppsed to one with map.
"6,monitor:eDP-1" (imap0 (monitorIndex: monitorName: (
"7,monitor:eDP-1" map (
"8,monitor:eDP-1" i: let
"9,monitor:eDP-1" # we define our own modulo operation for this,
"10,monitor:eDP-1" # since only the first workspace on each monitor is the default workspace.
mod = a: b: a - (b * (a / b));
# "1,monitor:HDMI-A-1, default:true" workspace = toString i;
# "2,monitor:HDMI-A-1" isDefault = (mod i 10) == 1; # 11, 21, 31, ...
# "3,monitor:HDMI-A-1" in "${workspace}, monitor:${monitorName}${optionalString isDefault ", default:true"}"
# "4,monitor:HDMI-A-1" )
# "5,monitor:HDMI-A-1" # we generate a list of 10 elements for each monitor. We have to add 1 each time since genList starts indexing at 0.
# "6,monitor:HDMI-A-1" # also, we add the monitorIndex * 10 to get 10 workspaces for each individual monitor.
# "7,monitor:HDMI-A-1" (genList (i: i + 1 + (10 * monitorIndex)) 10)
# "8,monitor:HDMI-A-1" ))
# "9,monitor:HDMI-A-1" # our attrSet of different monitors
# "10,monitor:HDMI-A-1" (attrNames monitors)))
# # These are my two special workspaces
# "11, monitor:HDMI-A-2, default:true" ++ [
# "12, monitor:HDMI-A-2" "special:nixos, decorate:false"
# "13, monitor:HDMI-A-2" "special:keepassxc, decorate:false"
# "14, monitor:HDMI-A-2" ];
# "15, monitor:HDMI-A-2"
# "16, monitor:HDMI-A-2"
# "17, monitor:HDMI-A-2"
# "18, monitor:HDMI-A-2"
# "19, monitor:HDMI-A-2"
# "20, monitor:HDMI-A-2"
#
# "21, monitor:DP-2, default:true"
# "22, monitor:DP-2"
# "23, monitor:DP-2"
# "24, monitor:DP-2"
# "25, monitor:DP-2"
# "26, monitor:DP-2"
# "27, monitor:DP-2"
# "28, monitor:DP-2"
# "29, monitor:DP-2"
# "30, monitor:DP-2"
#
# scratchpads
"special:nixos, decorate:false"
"special:keepassxc, decorate:false"
];
# Input settings # Input settings
input = { input = {
kb_layout = "de,us"; kb_layout = "de,us";
kb_variant = ",colemak_dh_wide"; kb_variant = ",colemak_dh_wide";
kb_options = "grp:rctrl_rshift_toggle"; kb_options = "grp:rctrl_rshift_toggle";
sensitivity = 0.0;
follow_mouse = true; follow_mouse = true;
repeat_rate = 50; repeat_rate = 50;
@ -226,80 +203,53 @@ in {
]; ];
# Keybinds # Keybinds
bind = [ bind =
"$mainMod, RETURN, exec, ${pkgs.foot}/bin/foot"
"$mainMod, Q, killactive"
"$mainMod, F, fullscreen, 0"
"$mainMod, D, exec, ${pkgs.procps}/bin/pkill fuzzel || ${pkgs.fuzzel}/bin/fuzzel"
"$mainMod, SPACE, togglefloating, active"
# workspaces # workspaces
# split-workspace is because of the split-workspace plugin # split-workspace is because of the split-workspace plugin
"$mainMod, 1, workspace, 1" map (
"$mainMod, 2, workspace, 2" i: let
"$mainMod, 3, workspace, 3" mod = a: b: a - (b * (a / b));
"$mainMod, 4, workspace, 4" key = toString (mod i 10);
"$mainMod, 5, workspace, 5" workspace = toString i;
"$mainMod, 6, workspace, 6" in "$mainMod, ${key}, split-workspace, ${workspace}"
"$mainMod, 7, workspace, 7" ) (genList (i: i + 1) 10)
"$mainMod, 8, workspace, 8" # split-movetoworkspacesilent
"$mainMod, 9, workspace, 9" ++ map (
"$mainMod, 0, workspace, 10" i: let
"$mainMod SHIFT, 1, movetoworkspacesilent, 1" mod = a: b: a - (b * (a / b));
"$mainMod SHIFT, 2, movetoworkspacesilent, 2" key = toString (mod i 10);
"$mainMod SHIFT, 3, movetoworkspacesilent, 3" workspace = toString i;
"$mainMod SHIFT, 4, movetoworkspacesilent, 4" in "$mainMod SHIFT, ${key}, split-movetoworkspacesilent, ${workspace}"
"$mainMod SHIFT, 5, movetoworkspacesilent, 5" ) (genList (i: i + 1) 10)
"$mainMod SHIFT, 6, movetoworkspacesilent, 6" ++ [
"$mainMod SHIFT, 7, movetoworkspacesilent, 7" "$mainMod, RETURN, exec, ${pkgs.foot}/bin/foot"
"$mainMod SHIFT, 8, movetoworkspacesilent, 8" "$mainMod, Q, killactive"
"$mainMod SHIFT, 9, movetoworkspacesilent, 9" "$mainMod, F, fullscreen, 0"
"$mainMod SHIFT, 0, movetoworkspacesilent, 10" "$mainMod, D, exec, ${pkgs.procps}/bin/pkill fuzzel || ${pkgs.fuzzel}/bin/fuzzel"
"$mainMod, SPACE, togglefloating, active"
# split-workspace is because of the split-workspace plugin # Move Windows
# "$mainMod, 1, split-workspace, 1" "$mainMod SHIFT, H, movewindow, l"
# "$mainMod, 2, split-workspace, 2" "$mainMod SHIFT, J, movewindow, d"
# "$mainMod, 3, split-workspace, 3" "$mainMod SHIFT, K, movewindow, u"
# "$mainMod, 4, split-workspace, 4" "$mainMod SHIFT, L, movewindow, r"
# "$mainMod, 5, split-workspace, 5"
# "$mainMod, 6, split-workspace, 6"
# "$mainMod, 7, split-workspace, 7"
# "$mainMod, 8, split-workspace, 8"
# "$mainMod, 9, split-workspace, 9"
# "$mainMod, 0, split-workspace, 10"
# "$mainMod SHIFT, 1, split-movetoworkspacesilent, 1"
# "$mainMod SHIFT, 2, split-movetoworkspacesilent, 2"
# "$mainMod SHIFT, 3, split-movetoworkspacesilent, 3"
# "$mainMod SHIFT, 4, split-movetoworkspacesilent, 4"
# "$mainMod SHIFT, 5, split-movetoworkspacesilent, 5"
# "$mainMod SHIFT, 6, split-movetoworkspacesilent, 6"
# "$mainMod SHIFT, 7, split-movetoworkspacesilent, 7"
# "$mainMod SHIFT, 8, split-movetoworkspacesilent, 8"
# "$mainMod SHIFT, 9, split-movetoworkspacesilent, 9"
# "$mainMod SHIFT, 0, split-movetoworkspacesilent, 10"
#
# Move Windows
"$mainMod SHIFT, H, movewindow, l"
"$mainMod SHIFT, J, movewindow, d"
"$mainMod SHIFT, K, movewindow, u"
"$mainMod SHIFT, L, movewindow, r"
# Screenshotting # Screenshotting
"$mainMod, S, exec, ${pkgs.grimblast}/bin/grimblast copy area" "$mainMod, S, exec, ${pkgs.grimblast}/bin/grimblast copy area"
# File manager # File manager
"$mainMod, E, exec, ${pkgs.xfce.thunar}/bin/thunar" "$mainMod, E, exec, ${pkgs.xfce.thunar}/bin/thunar"
# Toggle the three different special workspaces. # Toggle the three different special workspaces.
"$mainMod, N, togglespecialworkspace, nixos" "$mainMod, N, togglespecialworkspace, nixos"
"$mainMod, X, togglespecialworkspace, keepassxc" "$mainMod, X, togglespecialworkspace, keepassxc"
# Reload hyprland # Reload hyprland
"$mainMod, R, exec, ${cfg.package}/bin/hyprctl reload" "$mainMod, R, exec, ${cfg.package}/bin/hyprctl reload"
# Restart waybar # Restart waybar
"$mainMod CONTROL, B, exec, ${pkgs.procps}/bin/pkill waybar || ${pkgs.waybar}/bin/waybar" "$mainMod CONTROL, B, exec, ${pkgs.procps}/bin/pkill waybar || ${pkgs.waybar}/bin/waybar"
]; ];
binde = [ binde = [
# window focus # window focus
@ -329,10 +279,15 @@ in {
bindle = let bindle = let
volume_up = "${pkgs.pamixer}/bin/pamixer -ui 5"; volume_up = "${pkgs.pamixer}/bin/pamixer -ui 5";
volume_down = "${pkgs.pamixer}/bin/pamixer -ud 5"; volume_down = "${pkgs.pamixer}/bin/pamixer -ud 5";
brightness_up = "${pkgs.brighnessctl}/bin/brighnessctl set +5%";
brightness_down = "${pkgs.brighnessctl}/bin/brighnessctl set 5%-";
in [ in [
", XF86AudioRaiseVolume, exec, ${volume_up}" ", XF86AudioRaiseVolume, exec, ${volume_up}"
", XF86AudioLowerVolume, exec, ${volume_down}" ", XF86AudioLowerVolume, exec, ${volume_down}"
", XF86MonBrighnessUp, exec, ${brightness_up}"
", XF86MonBrighnessDown, exec, ${brightness_down}"
]; ];
# Mouse settings # Mouse settings
bindm = [ bindm = [
"$mainMod, mouse:272, movewindow" "$mainMod, mouse:272, movewindow"