1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-09-30 02:07:28 +02:00

i3: add modifier option

This allows to easily change modifier key for default keybindings and
gives a possibility to reference specified value in other modules.

Fixes #147.
This commit is contained in:
Nikita Uvarov 2018-05-26 23:44:57 +02:00
parent cacb8d410e
commit 30c97391d7
No known key found for this signature in database
GPG key ID: F7A5FB3A7C10EF96

View file

@ -306,7 +306,8 @@ let
modifier = mkOption { modifier = mkOption {
type = types.enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ]; type = types.enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ];
default = "Mod1"; default = cfg.config.modifier;
defaultText = "i3.config.modifier";
description = "Modifier key that can be used to drag floating windows."; description = "Modifier key that can be used to drag floating windows.";
example = "Mod4"; example = "Mod4";
}; };
@ -382,64 +383,78 @@ let
''; '';
}; };
modifier = mkOption {
type = types.enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ];
default = "Mod1";
description = "Modifier key that is used for all default keybindings.";
example = "Mod4";
};
keybindings = mkOption { keybindings = mkOption {
type = types.attrs; type = types.attrs;
default = { default = {
"Mod1+Return" = "exec i3-sensible-terminal"; "${cfg.config.modifier}+Return" = "exec i3-sensible-terminal";
"Mod1+Shift+q" = "kill"; "${cfg.config.modifier}+Shift+q" = "kill";
"Mod1+d" = "exec ${pkgs.dmenu}/bin/dmenu_run"; "${cfg.config.modifier}+d" = "exec ${pkgs.dmenu}/bin/dmenu_run";
"Mod1+Left" = "focus left"; "${cfg.config.modifier}+Left" = "focus left";
"Mod1+Down" = "focus down"; "${cfg.config.modifier}+Down" = "focus down";
"Mod1+Up" = "focus up"; "${cfg.config.modifier}+Up" = "focus up";
"Mod1+Right" = "focus right"; "${cfg.config.modifier}+Right" = "focus right";
"Mod1+h" = "split h"; "${cfg.config.modifier}+h" = "split h";
"Mod1+v" = "split v"; "${cfg.config.modifier}+v" = "split v";
"Mod1+f" = "fullscreen toggle"; "${cfg.config.modifier}+f" = "fullscreen toggle";
"Mod1+s" = "layout stacking"; "${cfg.config.modifier}+s" = "layout stacking";
"Mod1+w" = "layout tabbed"; "${cfg.config.modifier}+w" = "layout tabbed";
"Mod1+e" = "layout toggle split"; "${cfg.config.modifier}+e" = "layout toggle split";
"Mod1+Shift+space" = "floating toggle"; "${cfg.config.modifier}+Shift+space" = "floating toggle";
"Mod1+1" = "workspace 1"; "${cfg.config.modifier}+1" = "workspace 1";
"Mod1+2" = "workspace 2"; "${cfg.config.modifier}+2" = "workspace 2";
"Mod1+3" = "workspace 3"; "${cfg.config.modifier}+3" = "workspace 3";
"Mod1+4" = "workspace 4"; "${cfg.config.modifier}+4" = "workspace 4";
"Mod1+5" = "workspace 5"; "${cfg.config.modifier}+5" = "workspace 5";
"Mod1+6" = "workspace 6"; "${cfg.config.modifier}+6" = "workspace 6";
"Mod1+7" = "workspace 7"; "${cfg.config.modifier}+7" = "workspace 7";
"Mod1+8" = "workspace 8"; "${cfg.config.modifier}+8" = "workspace 8";
"Mod1+9" = "workspace 9"; "${cfg.config.modifier}+9" = "workspace 9";
"Mod1+Shift+1" = "move container to workspace 1"; "${cfg.config.modifier}+Shift+1" = "move container to workspace 1";
"Mod1+Shift+2" = "move container to workspace 2"; "${cfg.config.modifier}+Shift+2" = "move container to workspace 2";
"Mod1+Shift+3" = "move container to workspace 3"; "${cfg.config.modifier}+Shift+3" = "move container to workspace 3";
"Mod1+Shift+4" = "move container to workspace 4"; "${cfg.config.modifier}+Shift+4" = "move container to workspace 4";
"Mod1+Shift+5" = "move container to workspace 5"; "${cfg.config.modifier}+Shift+5" = "move container to workspace 5";
"Mod1+Shift+6" = "move container to workspace 6"; "${cfg.config.modifier}+Shift+6" = "move container to workspace 6";
"Mod1+Shift+7" = "move container to workspace 7"; "${cfg.config.modifier}+Shift+7" = "move container to workspace 7";
"Mod1+Shift+8" = "move container to workspace 8"; "${cfg.config.modifier}+Shift+8" = "move container to workspace 8";
"Mod1+Shift+9" = "move container to workspace 9"; "${cfg.config.modifier}+Shift+9" = "move container to workspace 9";
"Mod1+Shift+c" = "reload"; "${cfg.config.modifier}+Shift+c" = "reload";
"Mod1+Shift+r" = "restart"; "${cfg.config.modifier}+Shift+r" = "restart";
"Mod1+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; "${cfg.config.modifier}+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'";
"Mod1+r" = "mode resize"; "${cfg.config.modifier}+r" = "mode resize";
}; };
defaultText = "Default i3 keybindings."; defaultText = "Default i3 keybindings.";
description = '' description = ''
An attribute set that assignes key press to an action using key symbol. An attribute set that assigns a key press to an action using a key symbol.
See <link xlink:href="https://i3wm.org/docs/userguide.html#keybindings"/>. See <link xlink:href="https://i3wm.org/docs/userguide.html#keybindings"/>.
</para><para>
Consider to use <code>lib.mkOptionDefault</code> function to extend or override
default keybindings instead of specifying all of them from scratch.
''; '';
example = literalExample '' example = literalExample ''
{ let
"Mod1+Return" = "exec i3-sensible-terminal"; modifier = xsession.windowManager.i3.config.modifier;
"Mod1+Shift+q" = "kill"; in
"Mod1+d" = "exec ${pkgs.dmenu}/bin/dmenu_run";
lib.mkOptionDefault {
"''${modifier}+Return" = "exec i3-sensible-terminal";
"''${modifier}+Shift+q" = "kill";
"''${modifier}+d" = "exec \${pkgs.dmenu}/bin/dmenu_run";
} }
''; '';
}; };