Keyboard Layout Customization: Difference between revisions
imported>Heartbeast42 For the section on xmodmap: Fix heading size to match other headings, make heading clearer, reframe copy to be more general rather than being about 1 users experience. |
mNo edit summary |
||
Line 17: | Line 17: | ||
For desktop: | For desktop: | ||
< | <syntaxhighlight lang="nix"> | ||
services.xserver = { | services.xserver = { | ||
layout = "us,ru"; | layout = "us,ru"; | ||
Line 23: | Line 23: | ||
xkbOptions = "grp:win_space_toggle"; | xkbOptions = "grp:win_space_toggle"; | ||
}; | }; | ||
</ | </syntaxhighlight> | ||
For console: | For console: | ||
< | <syntaxhighlight lang="nix"> | ||
console.keyMap = "us"; | console.keyMap = "us"; | ||
</ | </syntaxhighlight> | ||
You can find valid values for these options in <code>$(nix-build --no-out-link '<nixpkgs>' -A xkeyboard_config)/etc/X11/xkb/rules/base.lst</code> | You can find valid values for these options in <code>$(nix-build --no-out-link '<nixpkgs>' -A xkeyboard_config)/etc/X11/xkb/rules/base.lst</code> | ||
Line 40: | Line 40: | ||
To load this file at the start of the X session, add the following to your <code>configuration.nix</code>. The extra compilation step (<code>xkbcomp</code>) helps catching layout errors at build time. | To load this file at the start of the X session, add the following to your <code>configuration.nix</code>. The extra compilation step (<code>xkbcomp</code>) helps catching layout errors at build time. | ||
< | <syntaxhighlight lang="nix"> | ||
let | let | ||
compiledLayout = pkgs.runCommand "keyboard-layout" {} '' | compiledLayout = pkgs.runCommand "keyboard-layout" {} '' | ||
Line 47: | Line 47: | ||
in | in | ||
services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xkbcomp}/bin/xkbcomp ${compiledLayout} $DISPLAY"; | services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xkbcomp}/bin/xkbcomp ${compiledLayout} $DISPLAY"; | ||
</ | </syntaxhighlight> | ||
If you are using home-manager, you also need to prevent home-manager from managing the keyboard by having <code>home.keyboard = null;</code> in your home-manager configuration. | If you are using home-manager, you also need to prevent home-manager from managing the keyboard by having <code>home.keyboard = null;</code> in your home-manager configuration. | ||
Line 65: | Line 65: | ||
Some users have found xmodmap to be a helpful tool although reports of successful implementation are varied. | Some users have found xmodmap to be a helpful tool although reports of successful implementation are varied. | ||
< | <syntaxhighlight lang="nix"> | ||
cat /etc/nixos/configuration.nix | cat /etc/nixos/configuration.nix | ||
Line 84: | Line 84: | ||
''}" | ''}" | ||
</ | </syntaxhighlight> | ||
Works after boot and after suspend/resume. | Works after boot and after suspend/resume. | ||
Line 90: | Line 90: | ||
You may need to add some delay to make xmodmap command work. | You may need to add some delay to make xmodmap command work. | ||
< | <syntaxhighlight lang="nix"> | ||
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> |