1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-28 17:38:33 +02:00

i3: extend module

New options:
  i3.config.keycodebindings
  i3.config.window.commands
  i3.config.window.hideEdgeBorders
  i3.config.focus.mouseWarping
This commit is contained in:
Nikita Uvarov 2017-11-17 12:22:59 +01:00
parent 8045e56df2
commit 177565567e
No known key found for this signature in database
GPG Key ID: F7A5FB3A7C10EF96
2 changed files with 74 additions and 3 deletions

View File

@ -462,6 +462,18 @@ in
where --no-startup-id option is necessary. where --no-startup-id option is necessary.
''; '';
} }
{
time = "2017-11-17T10:36:10+00:00";
condition = config.xsession.windowManager.i3.enable;
message = ''
The i3 window manager module has been extended with the following options:
i3.config.keycodebindings
i3.config.window.commands
i3.config.window.hideEdgeBorders
i3.config.focus.mouseWarping
'';
}
]; ];
}; };
} }

View File

@ -101,6 +101,22 @@ let
}; };
}; };
windowCommandModule = types.submodule {
options = {
command = mkOption {
type = types.string;
description = "i3wm command to execute.";
example = "border pixel 1";
};
criteria = mkOption {
type = criteriaModule;
description = "Criteria of the windows on which command should be executed.";
example = { title = "x200: ~/work"; };
};
};
};
criteriaModule = types.attrs; criteriaModule = types.attrs;
configModule = types.submodule { configModule = types.submodule {
@ -130,6 +146,22 @@ let
default = 2; default = 2;
description = "Window border width."; description = "Window border width.";
}; };
hideEdgeBorders = mkOption {
type = types.enum [ "none" "vertical" "horizontal" "both" "smart" ];
default = "none";
description = "Hide window borders adjacent to the screen edges.";
};
commands = mkOption {
type = types.listOf windowCommandModule;
default = [];
description = ''
List of commands that should be executed on specific windows.
See <option>for_window</option> i3wm option documentation.
'';
example = [ { command = "border pixel 1"; criteria = { class = "XTerm"; }; } ];
};
}; };
}; };
default = {}; default = {};
@ -200,6 +232,15 @@ let
See <link xlink:href="https://i3wm.org/docs/userguide.html#_focus_wrapping"/> See <link xlink:href="https://i3wm.org/docs/userguide.html#_focus_wrapping"/>
''; '';
}; };
mouseWarping = mkOption {
type = types.bool;
default = true;
description = ''
Whether mouse cursor should be warped to the center of the window when switching focus
to a window on a different output.
'';
};
}; };
}; };
default = {}; default = {};
@ -271,9 +312,8 @@ let
}; };
defaultText = "Default i3 keybindings."; defaultText = "Default i3 keybindings.";
description = '' description = ''
An attribute set that assignes keypress to an action. An attribute set that assignes key press to an action using key symbol.
Only basic keybinding is supported (bindsym keycomb action), See <link xlink:href="https://i3wm.org/docs/userguide.html#keybindings"/>.
for more advanced setup use 'i3.extraConfig'.
''; '';
example = literalExample '' example = literalExample ''
{ {
@ -284,6 +324,16 @@ let
''; '';
}; };
keycodebindings = mkOption {
type = types.attrs;
default = {};
description = ''
An attribute set that assignes keypress to an action using key code.
See <link xlink:href="https://i3wm.org/docs/userguide.html#keybindings"/>.
'';
example = { "214" = "exec --no-startup-id /bin/script.sh"; };
};
colors = mkOption { colors = mkOption {
type = types.submodule { type = types.submodule {
options = { options = {
@ -454,6 +504,10 @@ let
mapAttrsToList (keycomb: action: "bindsym ${keycomb} ${action}") keybindings mapAttrsToList (keycomb: action: "bindsym ${keycomb} ${action}") keybindings
); );
keycodebindingsStr = keycodebindings: concatStringsSep "\n" (
mapAttrsToList (keycomb: action: "bindcode ${keycomb} ${action}") keycodebindings
);
colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ]; colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ];
criteriaStr = criteria: "[${concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria)}]"; criteriaStr = criteria: "[${concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria)}]";
@ -486,6 +540,7 @@ let
''; '';
floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable"; floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable";
windowCommandsStr = { command, criteria, ... }: "for_window ${criteriaStr criteria} ${command}";
startupEntryStr = { command, always, notification, workspace, ... }: '' startupEntryStr = { command, always, notification, workspace, ... }: ''
${if always then "exec_always" else "exec"} ${ ${if always then "exec_always" else "exec"} ${
@ -503,9 +558,11 @@ let
floating_modifier ${floating.modifier} floating_modifier ${floating.modifier}
new_window ${if window.titlebar then "normal" else "pixel"} ${toString window.border} new_window ${if window.titlebar then "normal" else "pixel"} ${toString window.border}
new_float ${if floating.titlebar then "normal" else "pixel"} ${toString floating.border} new_float ${if floating.titlebar then "normal" else "pixel"} ${toString floating.border}
hide_edge_borders ${window.hideEdgeBorders}
force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"} force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"}
focus_follows_mouse ${if focus.followMouse then "yes" else "no"} focus_follows_mouse ${if focus.followMouse then "yes" else "no"}
focus_on_window_activation ${focus.newWindow} focus_on_window_activation ${focus.newWindow}
mouse_warping ${if focus.mouseWarping then "output" else "none"}
client.focused ${colorSetStr colors.focused} client.focused ${colorSetStr colors.focused}
client.focused_inactive ${colorSetStr colors.focusedInactive} client.focused_inactive ${colorSetStr colors.focusedInactive}
@ -515,11 +572,13 @@ let
client.background ${colors.background} client.background ${colors.background}
${keybindingsStr keybindings} ${keybindingsStr keybindings}
${keycodebindingsStr keycodebindings}
${concatStringsSep "\n" (mapAttrsToList modeStr modes)} ${concatStringsSep "\n" (mapAttrsToList modeStr modes)}
${concatStringsSep "\n" (mapAttrsToList assignStr assigns)} ${concatStringsSep "\n" (mapAttrsToList assignStr assigns)}
${concatStringsSep "\n" (map barStr bars)} ${concatStringsSep "\n" (map barStr bars)}
${optionalString (gaps != null) gapsStr} ${optionalString (gaps != null) gapsStr}
${concatStringsSep "\n" (map floatingCriteriaStr floating.criteria)} ${concatStringsSep "\n" (map floatingCriteriaStr floating.criteria)}
${concatStringsSep "\n" (map windowCommandsStr window.commands)}
${concatStringsSep "\n" (map startupEntryStr startup)} ${concatStringsSep "\n" (map startupEntryStr startup)}
'' else "") + "\n" + cfg.extraConfig); '' else "") + "\n" + cfg.extraConfig);