Merge pull request #119952 from attila-lendvai/extraLayouts

nixos/doc/manual: refine extraLayouts, add warnings an test commands
This commit is contained in:
Michele Guerini Rocco 2021-04-25 21:06:49 +02:00 committed by GitHub
commit e035c1b417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 13 deletions

View File

@ -204,18 +204,18 @@
XKB XKB
</link> </link>
keyboard layouts using the option keyboard layouts using the option
<option> <option><link linkend="opt-services.xserver.extraLayouts">
<link linkend="opt-services.xserver.extraLayouts"> services.xserver.extraLayouts</link></option>.
services.xserver.extraLayouts </para>
</link> <para>
</option>.
As a first example, we are going to create a layout based on the basic US As a first example, we are going to create a layout based on the basic US
layout, with an additional layer to type some greek symbols by pressing the layout, with an additional layer to type some greek symbols by pressing the
right-alt key. right-alt key.
</para> </para>
<para> <para>
To do this we are going to create a <literal>us-greek</literal> file Create a file called <literal>us-greek</literal> with the following
with a <literal>xkb_symbols</literal> section. content (under a directory called <literal>symbols</literal>; it's
an XKB peculiarity that will help with testing):
</para> </para>
<programlisting> <programlisting>
xkb_symbols &quot;us-greek&quot; xkb_symbols &quot;us-greek&quot;
@ -231,14 +231,13 @@ xkb_symbols &quot;us-greek&quot;
}; };
</programlisting> </programlisting>
<para> <para>
To install the layout, the filepath, a description and the list of A minimal layout specification must include the following:
languages must be given:
</para> </para>
<programlisting> <programlisting>
<xref linkend="opt-services.xserver.extraLayouts"/>.us-greek = { <xref linkend="opt-services.xserver.extraLayouts"/>.us-greek = {
description = "US layout with alt-gr greek"; description = "US layout with alt-gr greek";
languages = [ "eng" ]; languages = [ "eng" ];
symbolsFile = /path/to/us-greek; symbolsFile = /yourpath/symbols/us-greek;
} }
</programlisting> </programlisting>
<note> <note>
@ -248,9 +247,27 @@ xkb_symbols &quot;us-greek&quot;
</para> </para>
</note> </note>
<para> <para>
The layout should now be installed and ready to use: try it by Applying this customization requires rebuilding several packages,
running <literal>setxkbmap us-greek</literal> and type and a broken XKB file can lead to the X session crashing at login.
<literal>&lt;alt&gt;+a</literal>. To change the default the usual Therefore, you're strongly advised to <emphasis role="strong">test
your layout before applying it</emphasis>:
<screen>
<prompt>$ </prompt>nix-shell -p xorg.xkbcomp
<prompt>$ </prompt>setxkbmap -I/yourpath us-greek -print | xkbcomp -I/yourpath - $DISPLAY
</screen>
</para>
<para>
You can inspect the predefined XKB files for examples:
<screen>
<prompt>$ </prompt>echo "$(nix-build --no-out-link '&lt;nixpkgs&gt;' -A xorg.xkeyboardconfig)/etc/X11/xkb/"
</screen>
</para>
<para>
Once the configuration is applied, and you did a logout/login
cycle, the layout should be ready to use. You can try it by e.g.
running <literal>setxkbmap us-greek</literal> and then type
<literal>&lt;alt&gt;+a</literal> (it may not get applied in your
terminal straight away). To change the default, the usual
<option> <option>
<link linkend="opt-services.xserver.layout"> <link linkend="opt-services.xserver.layout">
services.xserver.layout services.xserver.layout