36

The following happens on different Linuces:

When I'm in a virtual console, hold Alt and press or , the virtual ttys cycle. This is really annoying as I'm using fish-shell which also uses this key combo. I could remap fish's short cuts, but I don't want to. Instead I want to disable the linux function or remap it.

How can I disable or change the tty-cycling-key-combo?

13

You can use the loadkeys command to remap keys on the Linux console. The following lines define the key bindings to switch consoles (on a PC keyboard):

alt keycode 105 = Decr_Console
alt keycode 106 = Incr_Console

Load your own keymap file that overrides these bindings with an escape sequence that fish recognizes. To make a key send an escape sequence, you need to bind it to a key name of the form FNUMBER and define a character sequence for FNUMBER.

alt keycode 105 = F105
alt keycode 106 = F106
string F105 = "\033\033[D"
string F105 = "\033\033[C"

Different distributions (and sometimes different packages for console support) store the system boot-time keymap in different locations under /etc. Look for a file called *.kmap or *.kmap.gz or *.map or *.map.gz under /etc or consult your distribution's manual. Some distributions store a the keymap's name in /etc instead and put the actual keymap elsewhere; look for a keymap-related setting under /etc/sysconfig or other configuration directory.

You can either write your own keymap and use include "/path/to/foo.map" to reference the system keymap, or arrange to load your own keymap containing just the settings you want to change during the boot process.

  • Are you sure about the .kmap extension? I wasn't able to find any files on Fedora 20, but on the other hand I found /lib/kbd/keymaps/legacy/i386/qwerty/us.map.gz. – Cristian Ciupitu Jul 24 '14 at 0:38
  • @CristianCiupitu My bad, I should have mentioned other ways this can be done. I think that on Fedora there's a setting somewhere in /etc/sysconfig that determines the name of the keymap file to load on startup. – Gilles Jul 24 '14 at 0:46
  • Should I get my setup with dumpkeys, save it, change it and change it in /etc/sysconfig? Will that make it persistent? – Max Ried Jul 24 '14 at 1:41
  • @Gilles, perhaps the man pages for systemd-vconsole-setup.service and [vconsole.conf ](freedesktop.org/software/systemd/man/vconsole.conf.html) can shed some light on this. – Cristian Ciupitu Jul 24 '14 at 2:46
  • @MaxRied I recommend keeping the two separate, it'll be easier to maintain. Change the reference in /etc/sysconfig to a file that contains an include directive to the standard keymap. – Gilles Jul 24 '14 at 7:38
43

Here's a one-off fix:

sudo sh -c 'dumpkeys |grep -v cr_Console |loadkeys'
20

I refactored Tobu's answer to change only the absolutely necessary:

sudo sh -c 'dumpkeys -k|grep -v Incr_Console|grep -v Decr_Console|grep -v Last_Console|loadkeys'

NB: As said this is a one-off fix, and will probably be gone after a reboot.

  • 1
    Two fixes: 1. Dump only key bindings, to avoid a syntax error in loadkeys; 2. Also get rid of Last_Console (Alt+Tab): sudo sh -c 'dumpkeys|grep -v Incr_Console|grep -v Decr_Console|loadkeys' Thanks very much for this! – Reuben Thomas Apr 4 '17 at 21:20
  • Further to my previous comment, I discovered that the Caps Lock light was still going on and off (even though Caps Lock was still mapped to Control on my system). To fix this, filtering out the line containing Caps_Lock does not work, as it's the only mapping for the relevant keycode, so is not overwritten when the filtered list of mappings is reloaded. In the end, the simplest solution was to dump a "known good" keymap, and then explicitly load that. – Reuben Thomas Apr 5 '17 at 9:16
13

I had the problem sometimes with Ubuntu 18.04:

sudo kbd_mode -s

Did the job. (at least temporarily)

You can find a long bug report here on launchpad .

  • How does this work? I am hesitant to experiment because the man page says "Warning: changing the keyboard mode, other than between ASCII and Unicode, will probably make your keyboard unusable." – nshiff Sep 9 '18 at 15:57
  • 1
    Hi, I have added a link. – COil Sep 9 '18 at 16:32
  • Thanks! This worked. I tried to click "Yes, it affects me" at bugs.launchpad.net/ubuntu/+source/console-setup/+bug/520546 but I keeping getting a timeout error. Any idea how to fix that? – 6005 Apr 21 at 17:41
  • It should be temporarily I suppose or you must full a bug report for the bug reporting system itself! :p – COil Apr 23 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.