fix movement binds

This commit is contained in:
Leonardo Eugênio 2022-08-07 16:58:23 -03:00
parent 22a1f5e5f2
commit 7ec137dd4c

View file

@ -105,6 +105,19 @@ in {
# Output: {v1=1;v2=2;} # Output: {v1=1;v2=2;}
mergeAttrsSet = lib.foldAttrs (n: _: n) { }; mergeAttrsSet = lib.foldAttrs (n: _: n) { };
forEachMerge = list: func: mergeAttrsSet (lib.forEach list func);
# same as imap0 but reversed inputs
iforEach0 = (list: func: lib.imap0 func list);
# Usefull for translating an imperative foreach into declarative attrset creation
# iforEach0mergeAttrsSet ["val1" "val2"] (i: v: {
# ${i} = v;
# })
# Ouput: {val1 = 1; val2 = 2;}
iforEach0mergeAttrsSet = list: func:
mergeAttrsSet (iforEach0 list func);
# mod+1 to swich to workspace 1 # mod+1 to swich to workspace 1
# mod+shift+1 to move to workspace 1 # mod+shift+1 to move to workspace 1
workspace_binds = let workspace_binds = let
@ -149,48 +162,38 @@ in {
]; ];
in mergeAttrsSet (prev_binds ++ next_binds); in mergeAttrsSet (prev_binds ++ next_binds);
movement_binds = { # focus, move, resize, (focus and move output)
"${mod}+${key.left}" = "focus left"; # for every direction with both arrow keys and vim keys
"${mod}+${key.down}" = "focus down"; movement_binds = let
"${mod}+${key.up}" = "focus up"; directions = [ "Left" "Up" "Right" "Down" ];
"${mod}+${key.right}" = "focus right"; makeVimKeys = (k: key.${lib.toLower k});
"${mod}+Left" = "focus left"; makeArrowKeys = (k: k);
"${mod}+Down" = "focus down"; makeResizeCommand = direction:
"${mod}+Up" = "focus up"; {
"${mod}+Right" = "focus right"; Left = "shrink width 20px";
"${mod}+Shift+${key.left}" = "move left"; Up = "shrink height 20px";
"${mod}+Shift+${key.down}" = "move down"; Right = "grow width 20px";
"${mod}+Shift+${key.up}" = "move up"; Down = "grow height 20px";
"${mod}+Shift+${key.right}" = "move right"; }.${direction};
"${mod}+Shift+Left" = "move left"; in forEachMerge [ makeVimKeys makeArrowKeys ] (prefixFun:
"${mod}+Shift+Down" = "move down"; forEachMerge directions (direction:
"${mod}+Shift+Up" = "move up"; let
"${mod}+Shift+Right" = "move right"; resize_cmd = makeResizeCommand direction;
"${mod}+Control+${key.left}" = "resize shrink width"; keyBind = prefixFun direction;
"${mod}+Control+${key.down}" = "resize grow height"; in {
"${mod}+Control+${key.up}" = "resize shrink height"; # Move focus
"${mod}+Control+${key.right}" = "resize grow width"; "${mod}+${keyBind}" = "focus ${direction}";
"${mod}+Control+Left" = "resize shrink width"; # Move window
"${mod}+Control+Down" = "resize grow height"; "${mod}+Shift+${keyBind}" = "move ${direction}";
"${mod}+Control+Up" = "resize shrink height"; # Resize window
"${mod}+Control+Right" = "resize grow width"; "${mod}+Control+${keyBind}" = "resize ${resize_cmd}";
"${mod}+mod1+${key.left}" = "focus output left"; # focus output
"${mod}+mod1+${key.down}" = "focus output down"; "${mod}+mod1+${keyBind}" = "focus output ${direction}";
"${mod}+mod1+${key.up}" = "focus output up"; # Move workspace to output
"${mod}+mod1+${key.right}" = "focus output right"; "${mod}+mod1+Shift+${keyBind}" =
"${mod}+mod1+Left" = "focus output left"; "move workspace output ${direction}";
"${mod}+mod1+Down" = "focus output down"; }));
"${mod}+mod1+Up" = "focus output up";
"${mod}+mod1+Right" = "focus output right";
"${mod}+mod1+Shift+${key.left}" = "move workspace output left";
"${mod}+mod1+Shift+${key.down}" = "move workspace output down";
"${mod}+mod1+Shift+${key.up}" = "move workspace output up";
"${mod}+mod1+Shift+${key.right}" = "move workspace output right";
"${mod}+mod1+Shift+Left" = "move workspace output left";
"${mod}+mod1+Shift+Down" = "move workspace output down";
"${mod}+mod1+Shift+Up" = "move workspace output up";
"${mod}+mod1+Shift+Right" = "move workspace output right";
};
audio_binds = { audio_binds = {
XF86AudioRaiseVolume = XF86AudioRaiseVolume =
"exec pactl set-sink-volume @DEFAULT_SINK@ +10%"; "exec pactl set-sink-volume @DEFAULT_SINK@ +10%";