diff options
Diffstat (limited to 'modules/desktop/window-manager/sxhkd')
| -rw-r--r-- | modules/desktop/window-manager/sxhkd/default.nix | 79 | ||||
| -rw-r--r-- | modules/desktop/window-manager/sxhkd/scripts/show-keybindings.sh | 13 |
2 files changed, 92 insertions, 0 deletions
diff --git a/modules/desktop/window-manager/sxhkd/default.nix b/modules/desktop/window-manager/sxhkd/default.nix new file mode 100644 index 0000000..29261b9 --- /dev/null +++ b/modules/desktop/window-manager/sxhkd/default.nix @@ -0,0 +1,79 @@ +{ pkgs, config, lib, ... }: + +{ + options = { + sxhkd.enable = lib.mkEnableOption "Enables sxhkd."; + }; + + config = lib.mkIf config.sxhkd.enable { + services.sxhkd.enable = true; + + services.sxhkd.keybindings = + let + modKey = "alt"; + createKeybinding = keybinding: description: "# ${description}\n${modKey} + ${keybinding}"; + in { + ${(createKeybinding + "s" + "Show keybindings.")} + = pkgs.writeShellScript + "show-keybindings.sh" + (builtins.readFile ./scripts/show-keybindings.sh); + + ${(createKeybinding + "r" + "Launch rofi.")} + = "rofi -show run"; + + ${(createKeybinding + "t" + "Launch terminal.")} + = "alacritty"; + + ${(createKeybinding + "f" + "Launch File Explorer.")} + = "alacritty -t 'File Explorer' --class 'popup' -e lf"; + + ${(createKeybinding + "q" + "Kill current window.")} + = "bspc node -c"; + + ${(createKeybinding + "{1-9,0}" + "Switch workspace.")} + = "bspc desktop -f {1-9,10}"; + + ${(createKeybinding + "shift + {1-9,0}" + "Move window to workspace.")} + = "bspc node -d {1-9,10} --follow"; + + ${(createKeybinding + "{n,d,m}" + "Set current window mode (tiled, floating, fullscreen).")} + = "bspc node focused -t {tiled,floating,fullscreen}"; + + ${(createKeybinding + "{_,shift + }{h,j,k,l}" + "Navigate between windows.")} + = "bspc node --{focus,swap} {west,south,north,east}"; + + # the indentation for each line is required to work with the help prompt + ${(createKeybinding + "ctrl + {h,j,k,l}" + "Resize current window.")} + = '' + {bspc node @parent/second -z left -20 0; \ + bspc node @parent/first -z right -20 0, \ + bspc node @parent/second -z top 0 +20; \ + bspc node @parent/first -z bottom 0 +20, \ + bspc node @parent/first -z bottom 0 -20; \ + bspc node @parent/second -z top 0 -20, \ + bspc node @parent/first -z right +20 0; \ + bspc node @parent/second -z left +20 0} + ''; + }; + }; +} diff --git a/modules/desktop/window-manager/sxhkd/scripts/show-keybindings.sh b/modules/desktop/window-manager/sxhkd/scripts/show-keybindings.sh new file mode 100644 index 0000000..db7863d --- /dev/null +++ b/modules/desktop/window-manager/sxhkd/scripts/show-keybindings.sh @@ -0,0 +1,13 @@ +#!/bin/sh +SXHKD_CONFIG="$HOME/.config/sxhkd/sxhkdrc" + +awk ' + /^#/ { + desc = substr($0, 3) + } + /^[[:alnum:]]/ { + cmd = $0 + getline + print cmd " : " desc + } +' "$SXHKD_CONFIG" | rofi -dmenu -i -p "Keybindings" |
