key remaps no longer work

Bug #140786 reported by mon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
console-tools (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: console-tools

Hi

I've made some changes in the file /etc/console-tools/remap that no longer work (I really don't know as of when..):
# This sed script is run across the dumpkeys output to remap keys on the console

# This turns caps lock into control
#s/keycode 58 = Caps_Lock/keycode 58 = Control/;

# This turns right apple key into alt-gr
s/keycode 126 =/keycode 126 = AltGr/;

This is a macbook pro core 2 duo. This remap worked in feisty but in gutsy x86 up to date it no longer work.

$ apt-cache policy console-tools
console-tools:
  Instalados: 1:0.2.3dbs-65ubuntu4
  Candidato: 1:0.2.3dbs-65ubuntu4
  Tabla de versión:
 *** 1:0.2.3dbs-65ubuntu4 0
        500 http://archive.ubuntu.com gutsy/main Packages
        100 /var/lib/dpkg/status

Thanks

Revision history for this message
mon (javiermon-deactivatedaccount) wrote :

Any ideas on how to fix this?

Revision history for this message
mon (javiermon-deactivatedaccount) wrote :

I've used xev and it's telling me my right apple key is 116. I've added:
s/keycode 116 =/keycode 116 = AltGr/;

and it didn't work. I've then look and saw the dumpkeys command says 116 is Do. so I've added:
s/keycode 116 = Do/keycode 116 = AltGr/;

with no luck.

Revision history for this message
mon (javiermon-deactivatedaccount) wrote :

I get this error:

root@macbook:~# dumpkeys < /dev/tty1 | sed -f /etc/console-tools/remap | loadkeys --quiet
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
se encontró un símbolo nulo
unknown keysym 'trademark'
:433: syntax error
error de sintaxis en archivo de mapa
Las asociaciones de tecla no se han cambiado

with this remap file:
# This sed script is run across the dumpkeys output to remap keys on the console

# This turns caps lock into control
#s/keycode 58 = Caps_Lock/keycode 58 = Control/;
s/keycode 126 =/keycode 126 = AltGr/;
s/keycode 116 = Do/keycode 116 = AltGr/;

Revision history for this message
mon (javiermon-deactivatedaccount) wrote :

I've changed the file to:

# This sed script is run across the dumpkeys output to remap keys on the console

# This turns caps lock into control
#s/keycode 58 = Caps_Lock/keycode 58 = Control/;
s/keycode 126 = Alt/keycode 126 = AltGr/;

and running as root:
dumpkeys < /dev/tty1 | sed -f /etc/console-tools/remap | loadkeys

works, but once I reboot the key remap is gone.

Revision history for this message
mon (javiermon-deactivatedaccount) wrote :

For the record, I've tried this on intrepid alpha 3 live cd and it doesn't work either.

Revision history for this message
feiy (eshangrao) wrote :

dumpkeys < /dev/tty1 | sed -f /etc/console-tools/remap | loadkeys
can replace the keymap,but after boot the keymap's reseted,and the remap not loaded!

confirmed in intrepid Alpha3

Changed in console-tools:
status: New → Confirmed
Revision history for this message
Nathan Collins (ntc2) wrote :

I've got this mostly figured out.

Short version
=============

1. Edit /etc/default/console-setup and add an X11 style caps lock modification:

$ diff -u console-setup.orig console-setup
--- console-setup.orig 2009-02-09 03:05:27.000000000 -0500
+++ console-setup 2009-02-09 03:59:31.000000000 -0500
@@ -37,7 +37,7 @@
 XKBMODEL="pc105"
 XKBLAYOUT="us"
 XKBVARIANT=""
-XKBOPTIONS=""
+XKBOPTIONS="ctrl:swapcaps"

you can do "ctrl:nocaps" instead if you want to two control keys.

2. Trick dpkg into integrating your changes:

$ sudo dpkg-reconfigure console-setup

and choose all the defaults. It will warn that you're using a keyboard setup it doesn't understand and is skipping keyboard configuration. I tried running the dkpg-reconfigure with the stock /etc/default/console-setup and it never prompted me for the xkboptions, so I think the warning can be ignored.

Your new control key setup should work immediately, and persist across reboots.

Long version
============

The console-tools package conflicts with the kbd package which is required by the ubuntu-minimal package (which I assume is essential). The kbd package installs a /etc/kbd/remap which does what /etc/console-tools/remap did. The /etc/kbd/remap gets integrated by /etc/init.d/console-screen.kbd.sh (lines 235-238) in runlevel S, but only if the setupcon program is not installed. However, setupcon is installed by the package console-setup, which is also a dependency of ubuntu-minimal, so the remap part gets skipped. So we have to use console-setup.

Now console-setup is apparently configured by /etc/default/console-setup, and the configuration would be integrated by /etc/init.d/keyboard-setup (also provided by console-setup) in runlevel S, except that init script skips the keyboard setup if usplash is running when the /etc/rcS.d scripts get run, and usplash is a dependency of ubuntu-desktop, so it probably is running. You can run the keyboard-setup script manually after making the above mentioned edit to /etc/default/console-setup to get the keymap changes temporarily, but they don't get applied on each boot.

But all is not lost, because when you run dpkg-reconfigure console-setup (as suggested by /usr/share/doc/console-setup/README.Debian to "fine-tune your keyboard setup") it makes your changes permanent, even though it's unable to configure the changes you actually made :P It says

* Saving console font and keymap for next boot... [ OK ]
update-initramfs: Generating /boot/initrd.img-2.6.27-11-generic

when it runs. I have no idea what's actually happening there, but someone who does can probably explain how to do this last part without having to actually run dpkg-reconfigure console-setup, which is a little annoying because you have to hit enter 15 times.

Revision history for this message
Buck Evan (bukzor) wrote :

This is what you're looking for:

            log_action_begin_msg "Saving console font and keymap for next boot"
            setupcon --save-only

From debian/keyboard-configuration.console-setup.init in this package: http://packages.ubuntu.com/oneiric/console-setup

This creates a cached keymap, like so:

. /etc/default/console-setup
. /etc/default/keyboard
ckbcomp $acm_option $rules_option -model "$XKBMODEL" \
                    "$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
                    | gzip -9 2>/dev/null >/etc/console-setup/cached.kmap.gz

The cached keymap is used when starting the 'console-setup' service: (/etc/init/console-setup.conf)
loadkeys /etc/console-setup/cached.kmap.gz

Putting it all together:

. /etc/default/console-setup
. /etc/default/keyboard
ckbcomp $acm_option $rules_option -model "$XKBMODEL" \
                    "$XKBLAYOUT" "$XKBVARIANT" "$XKBOPTIONS" \
                    | sed -f /etc/kbd/remap \
                    | gzip -9 2>/dev/null >/etc/console-setup/cached.kmap.gz
loadkeys /etc/console-setup/cached.kmap.gz

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.