Talk:Keyboard Layout Customization: Difference between revisions
imported>Itium Key symbols reference broken |
m Minor formatting tweaks (I somehow forgot that <syntaxhighlight lang="nix"> was a thing). |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
<code>xorg.xproto</code> seems not to exist anymore, so the command with <code>nix-build --no-out-link '<nixpkgs>' -A xorg.xproto</code> does not work anymore. Whats the correct replacement? --[[User:Itium|Itium]] ([[User talk:Itium|talk]]) 23:21, 9 January 2023 (UTC) | <code>xorg.xproto</code> seems not to exist anymore, so the command with <code>nix-build --no-out-link '<nixpkgs>' -A xorg.xproto</code> does not work anymore. Whats the correct replacement? --[[User:Itium|Itium]] ([[User talk:Itium|talk]]) 23:21, 9 January 2023 (UTC) | ||
== Incomplete application of the keyboard layout across environments == | |||
The current page shows decent basic and advanced configuration, but it does not apply the desired keyboard layout consistently across all environments. | |||
I only use a basic keyboard configuration, so I cannot speak for the Advanced part; However, I can do so for the simple configuration. | |||
For example, if one adds the following to their <b><code>configuration.nix</code></b>: | |||
<syntaxhighlight lang="nix"> | |||
services.xserver.xkb = { | |||
layout = "fr"; | |||
variant = ""; | |||
}; | |||
</syntaxhighlight> | |||
The keyboard layout is applied in most X11 environments, but not in the Linux Console (TTY) and not in certain Wayland compositors. | |||
The solution to this seems pretty simple to me: | |||
<ul> | |||
<li> Add the <b><code>console<span style="color: #ff5c00;">.</span>useXkbConfig <span style="color: #ff5c00;">=</span> <span style="color: #ff0080;">true</span><span style="color: #ff5c00;">;</span></code></b> option.</li> | |||
<li> Export <b><code>XKB_DEFAULT_</code></b>* variables with <b><code>environment<span style="color: #ff5c00;">.</span>variables <span style="color: #ff5c00;">=</span> <span style="color: #00a0ff;">{}</span><span style="color: #ff5c00;">;</span></code></b>, for example:</li> | |||
<syntaxhighlight lang="nix"> | |||
environment.variables = { | |||
XKB_DEFAULT_LAYOUT = config.services.xserver.xkb.layout; | |||
XKB_DEFAULT_VARIANT = config.services.xserver.xkb.variant; | |||
} | |||
</syntaxhighlight> | |||
</ul> | |||
In my experience, this allows the Linux Console to use the keyboard settings set with <b><code>services.xserver.xkb</code></b>, and allows "misbehaving" Wayland compositors to do the same. | |||
For example, this is my current <b><code>/etc/nixos/input/keyboard-layout.nix</code></b> module: | |||
<b><p style="white-space: pre-wrap; font-family: monospace; display: block; padding: 1rem; overflow-x: hidden; overflow-wrap: break-word; border: 1px solid; color: #dddddd; background-color: #1d1d24;"><span style="color: #00a0ff;">{</span> config<span style="color: #ff5c00;">, ...</span> <span style="color: #00a0ff;">}</span><span style="color: #ff5c00;">:</span> <span style="color: #00a0ff;">{</span> | |||
<span style="color: #0080ff"># Keyboard layout settings. | |||
# To see a complete list of layouts, variants, and other settings: | |||
# • <code style="background-color: #1d1d24; border-color: #333333;">https://gist.github.com/jatcwang/ae3b7019f219b8cdc6798329108c9aee</code> | |||
# | |||
# To see why this list cannot easily be seen within NixOS: | |||
# • <code style="background-color: #1d1d24; border-color: #333333;">https://github.com/NixOS/nixpkgs/issues/254523</code> | |||
# • <code style="background-color: #1d1d24; border-color: #333333;">https://github.com/NixOS/nixpkgs/issues/286283</code></span> | |||
services<span style="color: #ff5c00;">.</span>xserver<span style="color: #ff5c00;">.</span>xkb<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">layout</span> <span style="color: #ff5c00;">=</span> <span style="color: #e600ab">"us"</span><span style="color: #ff5c00;">;</span> | |||
services<span style="color: #ff5c00;">.</span>xserver<span style="color: #ff5c00;">.</span>xkb<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">variant</span> <span style="color: #ff5c00;">=</span> <span style="color: #e600ab">"intl"</span><span style="color: #ff5c00;">;</span> | |||
<span style="color: #0080ff"># Export the used keyboard layout. Some programs rely on this setting for it to be properly applied.</span> | |||
environment<span style="color: #ff5c00;">.</span>variables<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">XKB_DEFAULT_LAYOUT</span> <span style="color: #ff5c00;">=</span> config<span style="color: #ff5c00;">.</span>services<span style="color: #ff5c00;">.</span>xserver<span style="color: #ff5c00;">.</span>xkb<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">layout</span><span style="color: #ff5c00;">;</span> | |||
environment<span style="color: #ff5c00;">.</span>variables<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">XKB_DEFAULT_VARIANT</span> <span style="color: #ff5c00;">=</span> config<span style="color: #ff5c00;">.</span>services<span style="color: #ff5c00;">.</span>xserver<span style="color: #ff5c00;">.</span>xkb<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">variant</span><span style="color: #ff5c00;">;</span> | |||
<span style="color: #0080ff"># Whether to let the virtual console's (TTY's) keyboard layout be the same as the one configured above. | |||
# If false, it needs to be manually configured with the `console.keyMap` option.</span> | |||
console<span style="color: #ff5c00;">.</span><span style="color: #ffc000;">useXkbConfig</span> <span style="color: #ff5c00;">=</span> <span style="color: #ff0080;">true</span><span style="color: #ff5c00;">;</span> | |||
<span style="color: #00a0ff;">}</span> | |||
</p></b> | |||
<hr> | |||
On another note, there is the following line in this page: | |||
«<i>You can find valid values for these options in <b><code style="color: #00cc00; background-color: #000000;">$(nix-build --no-out-link '<nixpkgs>' -A xkeyboard_config)/etc/X11/xkb/rules/base.lst</code></b>»</i>, but this is incomplete, and also simply does not work. Removing this or fixing this would be great, though, I do not know how to do the latter. | |||
<!-- WHY did I write all of this by hand…? No idea, but it looks neat.--!> |
Latest revision as of 00:18, 4 September 2025
Key symbols reference broken
xorg.xproto
seems not to exist anymore, so the command with nix-build --no-out-link '<nixpkgs>' -A xorg.xproto
does not work anymore. Whats the correct replacement? --Itium (talk) 23:21, 9 January 2023 (UTC)
Incomplete application of the keyboard layout across environments
The current page shows decent basic and advanced configuration, but it does not apply the desired keyboard layout consistently across all environments. I only use a basic keyboard configuration, so I cannot speak for the Advanced part; However, I can do so for the simple configuration.
For example, if one adds the following to their configuration.nix
:
services.xserver.xkb = {
layout = "fr";
variant = "";
};
The keyboard layout is applied in most X11 environments, but not in the Linux Console (TTY) and not in certain Wayland compositors.
The solution to this seems pretty simple to me:
- Add the
console.useXkbConfig = true;
option. - Export
XKB_DEFAULT_
* variables withenvironment.variables = {};
, for example:
environment.variables = {
XKB_DEFAULT_LAYOUT = config.services.xserver.xkb.layout;
XKB_DEFAULT_VARIANT = config.services.xserver.xkb.variant;
}
In my experience, this allows the Linux Console to use the keyboard settings set with services.xserver.xkb
, and allows "misbehaving" Wayland compositors to do the same.
For example, this is my current /etc/nixos/input/keyboard-layout.nix
module:
On another note, there is the following line in this page:
«You can find valid values for these options in $(nix-build --no-out-link '<nixpkgs>' -A xkeyboard_config)/etc/X11/xkb/rules/base.lst
», but this is incomplete, and also simply does not work. Removing this or fixing this would be great, though, I do not know how to do the latter.