Talk:Keyboard Layout Customization: Difference between revisions
m Minor formatting tweaks (I somehow forgot that <syntaxhighlight lang="nix"> was a thing). |
|||
| Line 9: | Line 9: | ||
For example, if one adds the following to their <b><code>configuration.nix</code></b>: | For example, if one adds the following to their <b><code>configuration.nix</code></b>: | ||
< | <syntaxhighlight lang="nix"> | ||
layout | services.xserver.xkb = { | ||
variant | 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 keyboard layout is applied in most X11 environments, but not in the Linux Console (TTY) and not in certain Wayland compositors. | ||
| Line 20: | Line 21: | ||
<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> 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> | <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"> | ||
XKB_DEFAULT_LAYOUT | environment.variables = { | ||
XKB_DEFAULT_VARIANT | XKB_DEFAULT_LAYOUT = config.services.xserver.xkb.layout; | ||
XKB_DEFAULT_VARIANT = config.services.xserver.xkb.variant; | |||
</ | } | ||
</syntaxhighlight> | |||
</ul> | </ul> | ||
| Line 30: | Line 32: | ||
For example, this is my current <b><code>/etc/nixos/input/keyboard-layout.nix</code></b> module: | 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> | <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: # | <span style="color: #0080ff"># Keyboard layout settings. | ||
# To see a complete list of layouts, variants, and other settings: | # To see a complete list of layouts, variants, and other settings: | ||
# • <code>https://gist.github.com/jatcwang/ae3b7019f219b8cdc6798329108c9aee</code> | # • <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: | # To see why this list cannot easily be seen within NixOS: | ||
# • <code>https://github.com/NixOS/nixpkgs/issues/254523</code> | # • <code style="background-color: #1d1d24; border-color: #333333;">https://github.com/NixOS/nixpkgs/issues/254523</code> | ||
# • <code>https://github.com/NixOS/nixpkgs/issues/286283</code></span> | # • <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>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><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>variant <span style="color: #ff5c00;">=</span> <span style="color: #e600ab">"intl"</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: # | <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>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><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>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> | 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: # | <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> | # 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> | 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> | <span style="color: #00a0ff;">}</span> | ||
</p></b> | </p></b> | ||
| Line 55: | Line 57: | ||
On another note, there is the following line in this page: | 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. | «<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…? --!> | <!-- WHY did I write all of this by hand…? No idea, but it looks neat.--!> | ||