Keyboard Layout Customization: Difference between revisions

mNo edit summary
Fenhl (talk | contribs)
added keyd section
 
(4 intermediate revisions by 3 users not shown)
Line 9: Line 9:
The easiest way to customize your keyboard layout on NixOS is with these options:
The easiest way to customize your keyboard layout on NixOS is with these options:


* <code>services.xserver.layout</code>: Keyboard layout, or multiple keyboard layouts separated by commas.
* <code>services.xserver.xkb.layout</code>: Keyboard layout, or multiple keyboard layouts separated by commas.
* <code>services.xserver.xkbVariant</code>: X keyboard variant or multiple variants separated by commas (a variant can be empty).  
* <code>services.xserver.xkb.variant</code>: X keyboard variant or multiple variants separated by commas (a variant can be empty).  
* <code>services.xserver.xkbModel</code>: Keyboard model.
* <code>services.xserver.xkb.model</code>: Keyboard model.
* <code>services.xserver.xkbOptions</code>: X keyboard options; layout switching goes here.
* <code>services.xserver.xkb.options</code>: X keyboard options; layout switching goes here.


=====Example:=====
=====Example:=====
Line 18: Line 18:
For desktop:
For desktop:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
services.xserver = {
services.xserver.xkb = {
   layout = "us,ru";
   layout = "us,ru";
   xkbVariant = "workman,";
   # Note that the trailing comma is required: https://github.com/NixOS/nixpkgs/issues/359830
   xkbOptions = "grp:win_space_toggle";
  variant = "workman,";
   options = "grp:win_space_toggle";
};
};
</syntaxhighlight>
</syntaxhighlight>
Line 54: Line 55:


* <code>services.xserver.exportConfiguration</code>: Makes it so the above mentioned xkb directory (and the <code>xorg.conf</code> file) gets exported to <code>/etc/X11/xkb</code>, which is useful if you have to often look stuff up in it.
* <code>services.xserver.exportConfiguration</code>: Makes it so the above mentioned xkb directory (and the <code>xorg.conf</code> file) gets exported to <code>/etc/X11/xkb</code>, which is useful if you have to often look stuff up in it.
* <code>services.xserver.xkbDir</code>: Allows you to set a different xkb directory altogether. All the above mentioned things will use this instead of the default one in regards to xkb stuff.
* <code>services.xserver.xkb.dir</code>: Allows you to set a different xkb directory altogether. All the above mentioned things will use this instead of the default one in regards to xkb stuff.
* <code>console.useXkbConfig</code>: Makes it so the tty console has about the same layout as the one configured in the <code>services.xserver</code> options.
* <code>console.useXkbConfig</code>: Makes it so the tty console has about the same layout as the one configured in the <code>services.xserver</code> options.


Line 93: Line 94:
   services.xserver.displayManager.sessionCommands = "sleep 5 && ${pkgs.xorg.xmodmap}/bin/xmodmap -e 'keycode 43 = h H Left H' &";
   services.xserver.displayManager.sessionCommands = "sleep 5 && ${pkgs.xorg.xmodmap}/bin/xmodmap -e 'keycode 43 = h H Left H' &";
</syntaxhighlight>
</syntaxhighlight>
== Using keyd ==
[[keyd]] is another option to customize keyboard behavior, and may be useful when a single keypress should produce multiple characters at once, e.g. a letter with a combining diacritic.
[[Category:Desktop]]
[[Category:Hardware]]