Talk:Keyboard Layout Customization: Difference between revisions
imported>Itium Key symbols reference broken |
|||
| 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>: | |||
<b><p style="white-space: pre-wrap; font-family: monospace; display: block; padding: 1rem; overflow-x: hidden; overflow-wrap: break-word; border: 1px solid">services<span style="color: #ff5c00;">.</span>xserver<span style="color: #ff5c00;">.</span>xkb <span style="color: #ff5c00;">=</span> <span style="color: #00a0ff;">{</span> | |||
layout <span style="color: #ff5c00;">=</span> <span style="color: #e600ab">"fr"</span><span style="color: #ff5c00;">;</span> | |||
variant <span style="color: #ff5c00;">=</span> <span style="color: #e600ab">""</span><span style="color: #ff5c00;">;</span> | |||
<span style="color: #00a0ff;">}</span><span style="color: #ff5c00;">;</span> | |||
</p></b> | |||
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> | |||
<b><p style="white-space: pre-wrap; font-family: monospace; display: block; padding: 1rem; overflow-x: hidden; overflow-wrap: break-word; border: 1px solid">environment<span style="color: #ff5c00;">.</span>variables <span style="color: #ff5c00;">=</span> <span style="color: #00a0ff;">{</span> | |||
XKB_DEFAULT_LAYOUT <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>layout<span style="color: #ff5c00;">;</span> | |||
XKB_DEFAULT_VARIANT <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>variant<span style="color: #ff5c00;">;</span> | |||
<span style="color: #00a0ff;">}</span><span style="color: #ff5c00;">;</span> | |||
</p></b> | |||
</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"><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: #005cff"># Keyboard layout settings. | |||
# To see a complete list of layouts, variants, and other settings: | |||
# • <code>https://gist.github.com/jatcwang/ae3b7019f219b8cdc6798329108c9aee</code> | |||
# | |||
# To see why this list cannot easily be seen within NixOS: | |||
# • <code>https://github.com/NixOS/nixpkgs/issues/254523</code> | |||
# • <code>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>layout <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>variant <span style="color: #ff5c00;">=</span> <span style="color: #e600ab">"intl"</span><span style="color: #ff5c00;">;</span> | |||
<span style="color: #005cff"># 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>XKB_DEFAULT_LAYOUT <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>layout<span style="color: #ff5c00;">;</span> | |||
environment<span style="color: #ff5c00;">.</span>variables<span style="color: #ff5c00;">.</span>XKB_DEFAULT_VARIANT <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>variant<span style="color: #ff5c00;">;</span> | |||
<span style="color: #005cff"># 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>useXkbConfig <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;">$(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…? --!> ~~~~ | |||