aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/window-manager
diff options
context:
space:
mode:
Diffstat (limited to 'modules/desktop/window-manager')
-rw-r--r--modules/desktop/window-manager/bspwm/default.nix3
-rw-r--r--modules/desktop/window-manager/default.nix9
-rw-r--r--modules/desktop/window-manager/sxhkd/default.nix93
-rw-r--r--modules/desktop/window-manager/sxhkd/keybindings/bspwm.nix45
-rw-r--r--modules/desktop/window-manager/sxhkd/scripts/keybindings.sh (renamed from modules/desktop/window-manager/sxhkd/scripts/show-keybindings.sh)4
5 files changed, 86 insertions, 68 deletions
diff --git a/modules/desktop/window-manager/bspwm/default.nix b/modules/desktop/window-manager/bspwm/default.nix
index da9aa12..96df979 100644
--- a/modules/desktop/window-manager/bspwm/default.nix
+++ b/modules/desktop/window-manager/bspwm/default.nix
@@ -1,4 +1,4 @@
-{ config, lib, ... }:
+{ config, lib, pkgs, ... }:
{
options.desktop.window-manager.bspwm = {
@@ -6,6 +6,7 @@
};
config = lib.mkIf config.desktop.window-manager.bspwm.enable {
+ desktop.window-manager.default = "${pkgs.bspwm}/bin/bspwm";
xsession.windowManager.bspwm.enable = true;
xsession.windowManager.bspwm.settings = with config.scheme.withHashtag; {
diff --git a/modules/desktop/window-manager/default.nix b/modules/desktop/window-manager/default.nix
index c1de8c5..23c5d6e 100644
--- a/modules/desktop/window-manager/default.nix
+++ b/modules/desktop/window-manager/default.nix
@@ -1,8 +1,15 @@
-{ ... }:
+{ lib, ... }:
{
imports = [
./bspwm
./sxhkd
];
+
+ options.desktop.window-manager = {
+ default = lib.mkOption {
+ type = lib.types.str;
+ description = "Path to the default window manager program.";
+ };
+ };
}
diff --git a/modules/desktop/window-manager/sxhkd/default.nix b/modules/desktop/window-manager/sxhkd/default.nix
index 3673b48..decad25 100644
--- a/modules/desktop/window-manager/sxhkd/default.nix
+++ b/modules/desktop/window-manager/sxhkd/default.nix
@@ -12,68 +12,35 @@
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.")}
- = config.desktop.terminal.default;
-
- ${(createKeybinding
- "f"
- "Launch File Explorer.")}
- = "${config.desktop.terminal.default} -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}
- '';
- };
+ in lib.mkMerge [
+ (
+ if config.desktop.window-manager.bspwm.enable then
+ (import ./keybindings/bspwm.nix { inherit pkgs createKeybinding; })
+ else {}
+ )
+ {
+ ${(createKeybinding
+ "s"
+ "Show keybindings.")}
+ = pkgs.writeShellScript
+ "keybindings.sh"
+ (builtins.readFile ./scripts/keybindings.sh);
+
+ ${(createKeybinding
+ "r"
+ "Application launcher.")}
+ = config.desktop.popup-manager.application-launcher.default;
+
+ ${(createKeybinding
+ "t"
+ "Launch terminal.")}
+ = config.desktop.terminal.default;
+
+ ${(createKeybinding
+ "f"
+ "Launch File Manager.")}
+ = "${config.desktop.terminal.default} -t 'File Manager' --class popup -e ${config.tools.file-manager.default}";
+ }
+ ];
};
}
diff --git a/modules/desktop/window-manager/sxhkd/keybindings/bspwm.nix b/modules/desktop/window-manager/sxhkd/keybindings/bspwm.nix
new file mode 100644
index 0000000..1d66d16
--- /dev/null
+++ b/modules/desktop/window-manager/sxhkd/keybindings/bspwm.nix
@@ -0,0 +1,45 @@
+{ createKeybinding, pkgs }:
+
+let
+ bspc = "${pkgs.bspwm}/bin/bspc";
+in {
+ ${(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; \
+ @parent/first -z right -20 0, \
+ @parent/second -z top 0 +20; \
+ @parent/first -z bottom 0 +20, \
+ @parent/first -z bottom 0 -20; \
+ @parent/second -z top 0 -20, \
+ @parent/first -z right +20 0; \
+ @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/keybindings.sh
index db7863d..5e6b356 100644
--- a/modules/desktop/window-manager/sxhkd/scripts/show-keybindings.sh
+++ b/modules/desktop/window-manager/sxhkd/scripts/keybindings.sh
@@ -1,6 +1,4 @@
#!/bin/sh
-SXHKD_CONFIG="$HOME/.config/sxhkd/sxhkdrc"
-
awk '
/^#/ {
desc = substr($0, 3)
@@ -10,4 +8,4 @@ awk '
getline
print cmd " : " desc
}
-' "$SXHKD_CONFIG" | rofi -dmenu -i -p "Keybindings"
+' "$HOME/.config/sxhkd/sxhkdrc" | rofi -dmenu -i -p "Keybindings"