From 8ae4854de8906db7f898fe138204642146febadc Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Tue, 1 Dec 2020 11:58:19 -0500 Subject: fix(gs/system): Explicitly add all default i3 keybindings Something I changed - perhaps removing lib.mkOptionDefault - caused the *default* i3 keybindings (things like switching workspaces and toggling the split layout which I had not added myself) not to get added. This adds them back. Change-Id: I301a346eabb4f7fc4499b60a4c26956fb1e08b0d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2218 Reviewed-by: glittershark Tested-by: BuildkiteCI --- .../system/home/machines/chupacabra.nix | 2 + users/glittershark/system/home/modules/i3.nix | 140 ++++++++++++--------- 2 files changed, 84 insertions(+), 58 deletions(-) diff --git a/users/glittershark/system/home/machines/chupacabra.nix b/users/glittershark/system/home/machines/chupacabra.nix index 39478c672bd9..e9f27daa4408 100644 --- a/users/glittershark/system/home/machines/chupacabra.nix +++ b/users/glittershark/system/home/machines/chupacabra.nix @@ -59,4 +59,6 @@ in { ssh mugwump sudo $system/bin/switch-to-configuration switch '') ]; + + xsession.windowManager.i3.config.keybindings.F7 = "exec lock"; } diff --git a/users/glittershark/system/home/modules/i3.nix b/users/glittershark/system/home/modules/i3.nix index 54956e469e2e..499f4ed3b817 100644 --- a/users/glittershark/system/home/modules/i3.nix +++ b/users/glittershark/system/home/modules/i3.nix @@ -17,6 +17,9 @@ let --output DP-4 --off ''; }; + + inherit (builtins) map; + inherit (lib) mkMerge range; in { options = with lib; { system.machine.wirelessInterface = mkOption { @@ -51,6 +54,11 @@ in { # GIFs picom peek + + (pkgs.writeShellScriptBin "lock" '' + playerctl pause + ${pkgs.i3lock}/bin/i3lock -c 222222 + '') ]; xsession.scriptPath = ".xsession"; @@ -59,47 +67,60 @@ in { enable = true; config = { modifier = mod; - keybindings = lib.mkOptionDefault rec { - "${mod}+h" = "focus left"; - "${mod}+j" = "focus down"; - "${mod}+k" = "focus up"; - "${mod}+l" = "focus right"; - "${mod}+semicolon" = "focus parent"; - - "${mod}+Shift+h" = "move left"; - "${mod}+Shift+j" = "move down"; - "${mod}+Shift+k" = "move up"; - "${mod}+Shift+l" = "move right"; - - "${mod}+Shift+x" = "kill"; - - "${mod}+Return" = "exec alacritty"; - - "${mod}+Shift+s" = "split h"; - "${mod}+Shift+v" = "split v"; - - "${mod}+f" = "fullscreen"; - - "${mod}+Shift+r" = "restart"; - - "${mod}+r" = "mode resize"; - - # Marks - "${mod}+Shift+m" = ''exec i3-input -F "mark %s" -l 1 -P 'Mark: ' ''; - "${mod}+m" = ''exec i3-input -F '[con_mark="%s"] focus' -l 1 -P 'Go to: ' ''; - - # Screenshots - "${mod}+q" = "exec \"maim | xclip -selection clipboard -t image/png\""; - "${mod}+Shift+q" = "exec \"maim -s | xclip -selection clipboard -t image/png\""; - "${mod}+Ctrl+q" = "exec ${pkgs.writeShellScript "peek.sh" '' + keybindings = + mkMerge ( + (map + (n: { + "${mod}+${toString n}" = + "workspace ${toString n}"; + "${mod}+Shift+${toString n}" = + "move container to workspace ${toString n}"; + }) + (range 0 9)) + ++ [(rec { + "${mod}+h" = "focus left"; + "${mod}+j" = "focus down"; + "${mod}+k" = "focus up"; + "${mod}+l" = "focus right"; + "${mod}+semicolon" = "focus parent"; + + "${mod}+Shift+h" = "move left"; + "${mod}+Shift+j" = "move down"; + "${mod}+Shift+k" = "move up"; + "${mod}+Shift+l" = "move right"; + + "${mod}+Shift+x" = "kill"; + + "${mod}+Return" = "exec alacritty"; + + "${mod}+Shift+s" = "split h"; + "${mod}+Shift+v" = "split v"; + "${mod}+e" = "layout toggle split"; + "${mod}+w" = "layout tabbed"; + "${mod}+s" = "layout stacking"; + + "${mod}+f" = "fullscreen"; + + "${mod}+Shift+r" = "restart"; + + "${mod}+r" = "mode resize"; + + # Marks + "${mod}+Shift+m" = ''exec i3-input -F "mark %s" -l 1 -P 'Mark: ' ''; + "${mod}+m" = ''exec i3-input -F '[con_mark="%s"] focus' -l 1 -P 'Go to: ' ''; + + # Screenshots + "${mod}+q" = "exec \"maim | xclip -selection clipboard -t image/png\""; + "${mod}+Shift+q" = "exec \"maim -s | xclip -selection clipboard -t image/png\""; + "${mod}+Ctrl+q" = "exec ${pkgs.writeShellScript "peek.sh" '' ${pkgs.picom}/bin/picom & picom_pid=$! ${pkgs.peek}/bin/peek || true kill -SIGINT $picom_pid ''}"; - # Launching applications - "${mod}+u" = "exec ${pkgs.writeShellScript "rofi" '' + # Launching applications + "${mod}+u" = "exec ${pkgs.writeShellScript "rofi" '' rofi \ -modi 'combi' \ -combi-modi "window,drun,ssh,run" \ @@ -107,32 +128,35 @@ in { -show combi ''}"; - # Passwords - "${mod}+p" = "exec rofi-pass -font '${decorationFont}'"; - - # Media - "XF86AudioPlay" = "exec playerctl play-pause"; - "XF86AudioNext" = "exec playerctl next"; - "XF86AudioPrev" = "exec playerctl previous"; - "XF86AudioRaiseVolume" = "exec pulseaudio-ctl up"; - "XF86AudioLowerVolume" = "exec pulseaudio-ctl down"; - "XF86AudioMute" = "exec pulseaudio-ctl mute"; - - # Lock - Pause = "exec \"sh -c 'playerctl pause; ${pkgs.i3lock}/bin/i3lock -c 222222'\""; - F7 = Pause; - - # Screen Layout - "${mod}+Shift+t" = "exec xrandr --auto"; - "${mod}+t" = "exec ${screenlayout.home}"; - "${mod}+Ctrl+t" = "exec ${pkgs.writeShellScript "fix_term.sh" '' + # Passwords + "${mod}+p" = "exec rofi-pass -font '${decorationFont}'"; + + # Media + "XF86AudioPlay" = "exec playerctl play-pause"; + "XF86AudioNext" = "exec playerctl next"; + "XF86AudioPrev" = "exec playerctl previous"; + "XF86AudioRaiseVolume" = "exec pulseaudio-ctl up"; + "XF86AudioLowerVolume" = "exec pulseaudio-ctl down"; + "XF86AudioMute" = "exec pulseaudio-ctl mute"; + + # Lock + Pause = "exec lock"; + + # Sleep/hibernate + "${mod}+Escape" = "exec systemctl suspend"; + "${mod}+Shift+Escape" = "exec systemctl hibernate"; + + # Screen Layout + "${mod}+Shift+t" = "exec xrandr --auto"; + "${mod}+t" = "exec ${screenlayout.home}"; + "${mod}+Ctrl+t" = "exec ${pkgs.writeShellScript "fix_term.sh" '' xrandr --output eDP-1 --off && ${screenlayout.home} ''}"; - # Notifications - "${mod}+Shift+n" = "exec killall -SIGUSR1 .dunst-wrapped"; - "${mod}+n" = "exec killall -SIGUSR2 .dunst-wrapped"; - }; + # Notifications + "${mod}+Shift+n" = "exec killall -SIGUSR1 .dunst-wrapped"; + "${mod}+n" = "exec killall -SIGUSR2 .dunst-wrapped"; + })]); fonts = [ decorationFont ]; -- cgit 1.4.1