Where are the keymaps in Debian? (Using loadkeys to change keymap.)

From the actual console (e.g. Ctrl-Alt-F3), I'd like to use sudo loadkeys dvorak as in ubuntu. While that automagically works in Ubuntu, Debian wants me to locate a keymap file. I don't have the /usr/share/keymaps that is sometimes given as an answer. find / -type f -name '*dvorak*' turns up a few files which loadkeys won't take. As in this other answer I do not want to make a permanent change to my system using console-config. I want to write simple scripts that can change the keymap on the fly.

Is there a package I can install or something?

Since I'd like to swap Caps-Lock and Escape eventually, I should probably make my own custom keymaps, anyway, correct?


Solution 1:

1) Make sure console-data package is installed:

# loadkeys dvorak
Loading /usr/share/keymaps/i386/dvorak/dvorak.kmap.gz

$ dpkg --search /usr/share/keymaps/i386/dvorak/dvorak.kmap.gz
console-data: /usr/share/keymaps/i386/dvorak/dvorak.kmap.gz

$ cat /etc/debian_version 
wheezy/sid

2) IMHO, yes dumpkeys > test.keymap && edit test.keymap && loadkeys test is the easiest.

Solution 2:

This is a script from my personal poison cabinet which I use to permanently make CAPSLOCK an additional CTRL on debian. It should provide enough hints so you can further adapt it yourself.

It's assumed the 'us' kbd layout is used until now, new keyboard layout will be called 'sjas' here.

Oneliner:

apt install console-data -y; TMP=$(loadkeys us | awk {'print $2'}); TMP2=$(dirname $TMP)/sjas.kmap.gz; cp -vaf $TMP $TMP2; gzip -d $TMP2; TMP3=${TMP2%%.gz}; sed -i -e 's/us.map/sjas.map/' -e 's/.*58.*/keycode  58 = Control/' $TMP3; gzip -c $TMP3 > $TMP2; rm $TMP3; sed -i 's/"us"/"sjas"/g' /etc/default/keyboard

Not in one line, so it can be read easier:

apt install console-data -y
TMP=$(loadkeys us | awk {'print $2'})
TMP2=$(dirname $TMP)/sjas.kmap.gz
cp -vaf $TMP $TMP2
gzip -d $TMP2
TMP3=${TMP2%%.gz}
sed -i -e 's/us.map/sjas.map/' -e 's/.*58.*/keycode  58 = Control/' $TMP3
gzip -c $TMP3 > $TMP2
rm $TMP3
sed -i 's/"us"/"sjas"/g' /etc/default/keyboard

Replace 'sjas' and 'us' string occurrences with accordingly where your current layout differs and how you want to call your new one.