1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00
This commit is contained in:
Kovacsics Robert 2025-03-30 14:14:48 +02:00 committed by GitHub
commit 7963efaac3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 165 additions and 86 deletions

View file

@ -19,7 +19,14 @@ let
terminal defaultWorkspace workspaceOutputAssign;
keybindings = mkOption {
type = types.attrsOf (types.nullOr types.str);
type = let
withPriority = types.submodule {
options = {
priority = mkOption { type = types.int; };
value = mkOption { type = types.str; };
};
};
in types.attrsOf (types.nullOr (types.either types.str withPriority));
default = mapAttrs (n: mkOptionDefault) {
"${cfg.config.modifier}+Return" = "exec ${cfg.config.terminal}";
"${cfg.config.modifier}+Shift+q" = "kill";
@ -51,37 +58,87 @@ let
"${cfg.config.modifier}+Shift+minus" = "move scratchpad";
"${cfg.config.modifier}+minus" = "scratchpad show";
"${cfg.config.modifier}+1" = "workspace number 1";
"${cfg.config.modifier}+2" = "workspace number 2";
"${cfg.config.modifier}+3" = "workspace number 3";
"${cfg.config.modifier}+4" = "workspace number 4";
"${cfg.config.modifier}+5" = "workspace number 5";
"${cfg.config.modifier}+6" = "workspace number 6";
"${cfg.config.modifier}+7" = "workspace number 7";
"${cfg.config.modifier}+8" = "workspace number 8";
"${cfg.config.modifier}+9" = "workspace number 9";
"${cfg.config.modifier}+0" = "workspace number 10";
"${cfg.config.modifier}+1" = {
priority = 101;
value = "workspace number 1";
};
"${cfg.config.modifier}+2" = {
priority = 102;
value = "workspace number 2";
};
"${cfg.config.modifier}+3" = {
priority = 103;
value = "workspace number 3";
};
"${cfg.config.modifier}+4" = {
priority = 104;
value = "workspace number 4";
};
"${cfg.config.modifier}+5" = {
priority = 105;
value = "workspace number 5";
};
"${cfg.config.modifier}+6" = {
priority = 106;
value = "workspace number 6";
};
"${cfg.config.modifier}+7" = {
priority = 107;
value = "workspace number 7";
};
"${cfg.config.modifier}+8" = {
priority = 108;
value = "workspace number 8";
};
"${cfg.config.modifier}+9" = {
priority = 109;
value = "workspace number 9";
};
"${cfg.config.modifier}+0" = {
priority = 110;
value = "workspace number 10";
};
"${cfg.config.modifier}+Shift+1" =
"move container to workspace number 1";
"${cfg.config.modifier}+Shift+2" =
"move container to workspace number 2";
"${cfg.config.modifier}+Shift+3" =
"move container to workspace number 3";
"${cfg.config.modifier}+Shift+4" =
"move container to workspace number 4";
"${cfg.config.modifier}+Shift+5" =
"move container to workspace number 5";
"${cfg.config.modifier}+Shift+6" =
"move container to workspace number 6";
"${cfg.config.modifier}+Shift+7" =
"move container to workspace number 7";
"${cfg.config.modifier}+Shift+8" =
"move container to workspace number 8";
"${cfg.config.modifier}+Shift+9" =
"move container to workspace number 9";
"${cfg.config.modifier}+Shift+0" =
"move container to workspace number 10";
"${cfg.config.modifier}+Shift+1" = {
priority = 201;
value = "move container to workspace number 1";
};
"${cfg.config.modifier}+Shift+2" = {
priority = 202;
value = "move container to workspace number 2";
};
"${cfg.config.modifier}+Shift+3" = {
priority = 203;
value = "move container to workspace number 3";
};
"${cfg.config.modifier}+Shift+4" = {
priority = 204;
value = "move container to workspace number 4";
};
"${cfg.config.modifier}+Shift+5" = {
priority = 205;
value = "move container to workspace number 5";
};
"${cfg.config.modifier}+Shift+6" = {
priority = 206;
value = "move container to workspace number 6";
};
"${cfg.config.modifier}+Shift+7" = {
priority = 207;
value = "move container to workspace number 7";
};
"${cfg.config.modifier}+Shift+8" = {
priority = 208;
value = "move container to workspace number 8";
};
"${cfg.config.modifier}+Shift+9" = {
priority = 209;
value = "move container to workspace number 9";
};
"${cfg.config.modifier}+Shift+0" = {
priority = 210;
value = "move container to workspace number 10";
};
"${cfg.config.modifier}+Shift+c" = "reload";
"${cfg.config.modifier}+Shift+r" = "restart";
@ -140,7 +197,7 @@ let
inherit (commonFunctions)
keybindingsStr keycodebindingsStr modeStr assignStr barStr gapsStr
floatingCriteriaStr windowCommandsStr colorSetStr windowBorderString
fontConfigStr keybindingDefaultWorkspace keybindingsRest workspaceOutputStr;
fontConfigStr workspaceOutputStr;
startupEntryStr = { command, always, notification, workspace, ... }:
concatStringsSep " " [
@ -174,8 +231,7 @@ let
"client.urgent ${colorSetStr colors.urgent}"
"client.placeholder ${colorSetStr colors.placeholder}"
"client.background ${colors.background}"
(keybindingsStr { keybindings = keybindingDefaultWorkspace; })
(keybindingsStr { keybindings = keybindingsRest; })
keybindingsStr
(keycodebindingsStr keycodebindings)
] ++ mapAttrsToList (modeStr false) modes
++ mapAttrsToList assignStr assigns ++ map barStr bars

View file

@ -12,20 +12,45 @@ rec {
''${k}="${v}"'';
in "[${concatStringsSep " " (mapAttrsToList toCriteria criteria)}]";
keybindingDefaultWorkspace = filterAttrs (n: v:
cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace)
cfg.config.keybindings;
# Gets the value for something which may be either
#
# {name = ...; value = {priority = <int>; value = <value>; }; }
#
# or just a
#
# {name = ...; value = <value>; }
getPriorityValue = name-value:
if builtins.typeOf name-value.value == "set" && name-value.value ? priority
&& name-value.value ? value then
name-value.value.value
else
name-value.value;
keybindingsRest = filterAttrs (n: v:
cfg.config.defaultWorkspace == null || v != cfg.config.defaultWorkspace)
cfg.config.keybindings;
# Gets the priority if present, or 100 for defaultWorkspace and 1000 for
# anything else)
getPriority = name-value:
if cfg.config.defaultWorkspace != null && getPriorityValue name-value
== cfg.config.defaultWorkspace then
100
else if builtins.typeOf name-value.value == "set" && name-value.value
? priority && name-value.value ? value then
name-value.value.priority
else
1000;
keybindingsStr = { keybindings, bindsymArgs ? "", indent ? "" }:
concatStringsSep "\n" (mapAttrsToList (keycomb: action:
mapSortedAttrs = f: attrs:
builtins.map (name-value: f name-value.name (getPriorityValue name-value))
(builtins.sort (lhs: rhs: getPriority lhs < getPriority rhs)
(lib.attrsToList attrs));
makeKeybindingsStr = { keybindings, bindsymArgs ? "", indent ? "" }:
concatStringsSep "\n" (mapSortedAttrs (keycomb: action:
optionalString (action != null) "${indent}bindsym ${
lib.optionalString (bindsymArgs != "") "${bindsymArgs} "
}${keycomb} ${action}") keybindings);
keybindingsStr = makeKeybindingsStr { inherit (cfg.config) keybindings; };
keycodebindingsStr = keycodebindings:
concatStringsSep "\n" (mapAttrsToList (keycomb: action:
optionalString (action != null) "bindcode ${keycomb} ${action}")
@ -43,7 +68,7 @@ rec {
modeStr = bindkeysToCode: name: keybindings: ''
mode "${name}" {
${keybindingsStr {
${makeKeybindingsStr {
inherit keybindings;
bindsymArgs = lib.optionalString bindkeysToCode "--to-code";
indent = " ";

View file

@ -899,6 +899,8 @@ in {
if isSway then "sway" else "i3"
} is launched.
This must to correspond to the value of the keybinding of the default workspace.
Alternatively you can specify a priority for any keybinding, default
priority is 1000, keybinding matching defaultWorkspace priority is 100.
'';
example = "workspace number 9";
};

View file

@ -15,8 +15,6 @@ client.unfocused #333333 #222222 #888888 #292d2e #222222
client.urgent #2f343a #900000 #ffffff #900000 #900000
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
client.background #ffffff
bindsym Mod1+0 workspace number 10
bindsym Mod1+1 workspace number 1
bindsym Mod1+2 workspace number 2
bindsym Mod1+3 workspace number 3
@ -26,11 +24,7 @@ bindsym Mod1+6 workspace number 6
bindsym Mod1+7 workspace number 7
bindsym Mod1+8 workspace number 8
bindsym Mod1+9 workspace number 9
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+0 workspace number 10
bindsym Mod1+Shift+1 move container to workspace number 1
bindsym Mod1+Shift+2 move container to workspace number 2
bindsym Mod1+Shift+3 move container to workspace number 3
@ -40,6 +34,11 @@ bindsym Mod1+Shift+6 move container to workspace number 6
bindsym Mod1+Shift+7 move container to workspace number 7
bindsym Mod1+Shift+8 move container to workspace number 8
bindsym Mod1+Shift+9 move container to workspace number 9
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Right move right

View file

@ -15,8 +15,6 @@ client.unfocused #333333 #222222 #888888 #292d2e #222222
client.urgent #2f343a #900000 #ffffff #900000 #900000
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
client.background #ffffff
bindsym Mod1+0 workspace number 10
bindsym Mod1+1 workspace number 1
bindsym Mod1+2 workspace number 2
bindsym Mod1+3 workspace number 3
@ -26,11 +24,7 @@ bindsym Mod1+6 workspace number 6
bindsym Mod1+7 workspace number 7
bindsym Mod1+8 workspace number 8
bindsym Mod1+9 workspace number 9
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+0 workspace number 10
bindsym Mod1+Shift+1 move container to workspace number 1
bindsym Mod1+Shift+2 move container to workspace number 2
bindsym Mod1+Shift+3 move container to workspace number 3
@ -40,6 +34,11 @@ bindsym Mod1+Shift+6 move container to workspace number 6
bindsym Mod1+Shift+7 move container to workspace number 7
bindsym Mod1+Shift+8 move container to workspace number 8
bindsym Mod1+Shift+9 move container to workspace number 9
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Right move right

View file

@ -15,8 +15,6 @@ client.unfocused #333333 #222222 #888888 #292d2e #222222
client.urgent #2f343a #900000 #ffffff #900000 #900000
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
client.background #ffffff
bindsym Mod1+0 workspace number 10
bindsym Mod1+1 workspace number 1
bindsym Mod1+2 workspace number 2
bindsym Mod1+3 workspace number 3
@ -26,11 +24,7 @@ bindsym Mod1+6 workspace number 6
bindsym Mod1+7 workspace number 7
bindsym Mod1+8 workspace number 8
bindsym Mod1+9 workspace number 9
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+0 workspace number 10
bindsym Mod1+Shift+1 move container to workspace number 1
bindsym Mod1+Shift+2 move container to workspace number 2
bindsym Mod1+Shift+3 move container to workspace number 3
@ -40,6 +34,11 @@ bindsym Mod1+Shift+6 move container to workspace number 6
bindsym Mod1+Shift+7 move container to workspace number 7
bindsym Mod1+Shift+8 move container to workspace number 8
bindsym Mod1+Shift+9 move container to workspace number 9
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Right move right

View file

@ -15,23 +15,16 @@ client.unfocused #333333 #222222 #888888 #292d2e #222222
client.urgent #2f343a #900000 #ffffff #900000 #900000
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
client.background #ffffff
bindsym Mod1+0 workspace number 10
bindsym Mod1+5 workspace number 5
bindsym Mod1+1 workspace number 1
bindsym Mod1+2 workspace number 2
bindsym Mod1+3 workspace number 3
bindsym Mod1+4 workspace number 4
bindsym Mod1+5 workspace number 5
bindsym Mod1+6 workspace number 6
bindsym Mod1+7 workspace number 7
bindsym Mod1+8 workspace number 8
bindsym Mod1+9 workspace number 9
bindsym Mod1+Down focus down
bindsym Mod1+Invented invented-key-command
bindsym Mod1+Left overridden-command
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+0 workspace number 10
bindsym Mod1+Shift+1 move container to workspace number 1
bindsym Mod1+Shift+2 move container to workspace number 2
bindsym Mod1+Shift+3 move container to workspace number 3
@ -41,6 +34,12 @@ bindsym Mod1+Shift+6 move container to workspace number 6
bindsym Mod1+Shift+7 move container to workspace number 7
bindsym Mod1+Shift+8 move container to workspace number 8
bindsym Mod1+Shift+9 move container to workspace number 9
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+Down focus down
bindsym Mod1+Invented invented-key-command
bindsym Mod1+Left overridden-command
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Right move right

View file

@ -6,6 +6,7 @@
xsession.windowManager.i3 = {
enable = true;
config.defaultWorkspace = "workspace number 5";
config.keybindings =
let modifier = config.xsession.windowManager.i3.config.modifier;
in lib.mkOptionDefault {

View file

@ -16,7 +16,6 @@ client.urgent #2f343a #900000 #ffffff #900000 #900000
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
client.background #ffffff
bindsym Mod1+1 workspace number 1
bindsym Mod1+0 workspace number 10
bindsym Mod1+2 workspace number 2
bindsym Mod1+3 workspace number 3
bindsym Mod1+4 workspace number 4
@ -25,11 +24,7 @@ bindsym Mod1+6 workspace number 6
bindsym Mod1+7 workspace number 7
bindsym Mod1+8 workspace number 8
bindsym Mod1+9 workspace number 9
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+0 workspace number 10
bindsym Mod1+Shift+1 move container to workspace number 1
bindsym Mod1+Shift+2 move container to workspace number 2
bindsym Mod1+Shift+3 move container to workspace number 3
@ -39,6 +34,11 @@ bindsym Mod1+Shift+6 move container to workspace number 6
bindsym Mod1+Shift+7 move container to workspace number 7
bindsym Mod1+Shift+8 move container to workspace number 8
bindsym Mod1+Shift+9 move container to workspace number 9
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Right move right

View file

@ -15,8 +15,6 @@ client.unfocused #333333 #222222 #888888 #292d2e #222222
client.urgent #2f343a #900000 #ffffff #900000 #900000
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
client.background #ffffff
bindsym Mod1+0 workspace number 10
bindsym Mod1+1 workspace number 1
bindsym Mod1+2 workspace number 2
bindsym Mod1+3 workspace number 3
@ -26,11 +24,7 @@ bindsym Mod1+6 workspace number 6
bindsym Mod1+7 workspace number 7
bindsym Mod1+8 workspace number 8
bindsym Mod1+9 workspace number 9
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+0 workspace number 10
bindsym Mod1+Shift+1 move container to workspace number 1
bindsym Mod1+Shift+2 move container to workspace number 2
bindsym Mod1+Shift+3 move container to workspace number 3
@ -40,6 +34,11 @@ bindsym Mod1+Shift+6 move container to workspace number 6
bindsym Mod1+Shift+7 move container to workspace number 7
bindsym Mod1+Shift+8 move container to workspace number 8
bindsym Mod1+Shift+9 move container to workspace number 9
bindsym Mod1+Shift+0 move container to workspace number 10
bindsym Mod1+Down focus down
bindsym Mod1+Left focus left
bindsym Mod1+Return exec i3-sensible-terminal
bindsym Mod1+Right focus right
bindsym Mod1+Shift+Down move down
bindsym Mod1+Shift+Left move left
bindsym Mod1+Shift+Right move right