Talk:Linux console/Keyboard configuration

From ArchWiki

Reboot

I didn't edit the wiki, but I found that rebooting was necessary after using the localectl-command to set-keymap dvorak. Ive been in need of this solution for a _long_ time and was disappointed until rebooting. —This unsigned comment is by Addeps3 (talk) 11:42, 18 March 2017‎. Please sign your posts with ~~~~!

That's the obvious difference between a persistent and temporary configuration as the section titles indicate. -- Lahwaacz (talk) 12:39, 18 March 2017 (UTC)Reply

Colemak

Pro Tip—don't use KEYMAP_TOGGLE for colemak; just use KEYMAP=colemak. Kete (talk) 04:42, 10 March 2016 (UTC)Reply

Can you add any context? KEYMAP_TOGGLE isn't mentioned in the article. -- Alad (talk) 14:39, 10 March 2016 (UTC)Reply
Yes, in my old system, I saw the following.
KEYMAP=us
KEYMAP_TOGGLE=colemak
In the man page, I read that us is default, so I tried with only the KEYMAP_TOGGLE which didn't work on its own. --Kete (talk) 15:15, 10 March 2016 (UTC)Reply
Yes, systemd's vconsole.conf file supports a KEYMAP_TOGGLE variable, but it's completely undocumented and I guess nobody really knows what is the expected result. If you look at the source code, the KEYMAP_TOGGLE value is simply added to the argument list passed to loadkeys, but its documentation is just as lacking. There even isn't any definition of which combination of keys should be used for switching the layouts. Some keymaps seem to have a secondary layout built in (e.g. cz-us-qwertz with Pause key for switching). This actually works, but loadkeys is used to load a single keymap. If somebody could explain this to me, that would be great. Until then, I think the best recommendation is to not use KEYMAP_TOGGLE at all, not only for colemak. -- Lahwaacz (talk) 17:14, 10 March 2016 (UTC)Reply
So, is that combination of variables working in your "old" system? Maybe that's using an "old" init system that was actually supporting it somehow. Anyway I'm another Colemak typer, and in an up-to-date Arch system using KEYMAP=colemak is enough, there's no need to set KEYMAP_TOGGLEKynikos (talk) 07:38, 11 March 2016 (UTC)Reply

localctl list-keymaps

does not list the keymap file in /usr/local/share/kbd/keymaps. Should one make a copy under /usr/share/ instead. Both are system and not user folder.

—This unsigned comment is by Roland Puntaier (talk) 16:19, 26 June 2019‎. Please sign your posts with ~~~~!

/usr/share/ is not intended for custom files which are not provided by any package. -- Lahwaacz (talk) 13:50, 30 June 2019 (UTC)Reply

localectl doesn't appear to change /etc/vconsole.conf

“For convenience, localectl may be used to set console keymap. It will change the KEYMAP variable in /etc/vconsole.conf and also set the keymap for current session”

In my fresh Arch install, there is no /etc/vconsole.conf. Creating it, even with content, and then running # localectl set-keymap <some-keymap> doesn't affect the file at all. Can someone confirm/deny? Adrian5 (talk) 02:31, 12 March 2021 (UTC)Reply

It's even mentioned explicitly in the manpage: localectl(1). -- Lahwaacz (talk) 11:22, 13 March 2021 (UTC)Reply
And does it do that on your system? Adrian5 (talk) 12:41, 13 March 2021 (UTC)Reply
Yes, running localectl --no-convert set-keymap cz-qwertz changes the KEYMAP in /etc/vconsole.conf. -- Lahwaacz (talk) 15:51, 13 March 2021 (UTC)Reply

Custom keymap

I believe it currently makes more sense to put the custom keymap in /usr/share/kbd/keymaps/ rather than in /usr/local/share/kbd/keymaps/personal.

The main advantage is that sd-vconsole works with keymaps in /usr/share/kbd/keymaps/, and automatically puts them in the initramfs. The sd-vconsole script, /usr/lib/initcpio/install/sd-vconsole, also automatically adds the dependencies.

Alternatively, if we use /usr/local/share/kbd/keymaps/personal, we can add all required files using mkinitcpio BINARIES and FILES. But this is rather tedious, as if we include a common keymap such as us.map, we also have to include it's many dependencies. They currently are:

  • /usr/share/kbd/keymaps/i386/include/compose.inc
  • /usr/share/kbd/keymaps/i386/include/euro1.map
  • /usr/share/kbd/keymaps/i386/include/linux-keys-bare.inc
  • /usr/share/kbd/keymaps/i386/include/linux-with-alt-and-altgr.inc
  • /usr/share/kbd/keymaps/i386/include/qwerty-layout.inc
  • /usr/share/kbd/keymaps/i386/qwerty/personal.map
  • /usr/share/kbd/keymaps/i386/qwerty/us.map
  • /usr/share/kbd/keymaps/include/compose.latin1

These might change over time as well, breaking the keymap. Breaking the keymap also breaks the font that's specified in /etc/vconsole.conf. Once my font broke in this way, and it was quite hard for me to find out it was caused by my keymap being broken due to putting it in /usr/local/share/kbd/keymaps/personal and missing that file in initramfs.

I suggested allowing custom keymaps from other directories in https://bugs.archlinux.org/task/71788. Giancarlo Razzolini (Arch dev) is against this. We can of course add our custom initramfs hook script to remedy this situation, which I attached in that bug. But again this is a lot more complicated than simply putting the keymap in /usr/share/kbd/keymaps/. Simonzack (talk) 09:35, 4 September 2021 (UTC)Reply

Creating a custom keymap - How to add the default keymap in vconsole.conf

There is no information how to set up the personal.map in vconsole.conf so that the default keymap is preserved.

—This unsigned comment is by Kama (talk) 11:01, 8 October 2022. Please sign your posts with ~~~~!

Creating a custom keymap - Modifier keys

I think one has to be careful when redefining the behaviour of keys already treated by the default keymap. Following the wiki, in order to add another Control key I did sudo loadkeys /usr/local/share/kbd/keymaps/personal.map with

/usr/local/share/kbd/keymaps/personal.map
keycode 58 = Control

but then Control appears only in the first column of keycode 58 in dumpkeys -f; this creates problems, as mentioned in man keymaps (for instance after keycode 58+l I couldn't type). If instead I do the same but with

/usr/local/share/kbd/keymaps/personal.map
keymaps 0-2,4-6,8-9,12
keycode 58 = Control

then Control appears in every column of keycode 58 and everything works fine; this appears in https://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-15.html. I think it could be useful to mention something related to this in the wiki, since it is not explained in man loadkeys. Adveral (talk) 11:12, 9 April 2023 (UTC)Reply