Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have ubuntu (11.04) running on a recent macbook pro. I use both the built in keyboard and an external keyboard. I want to remap capslock on both keyboards to super, and I want to swap left-alt (mac option) and left-super (mac cmd) on the built in (apple) keyboard only.

Xmodmap can't configure multiple keyboards differently, so thats out.

I am able to do this from the cli via setkbmap. Here is the script I'm using:

#!/bin/sh
#set caps to super
setxkbmap -option caps:super

#swap command and option for apple keyboard
setxkbmap -device `xinput list | grep -o -P 'Apple Internal Keyboard / Trackpad\s+id=\d+' | grep -o -P '\d+'` -option altwin:swap_lalt_lwin

If I have to, I can run this as a startup application, but I would really like to know if there is a configuration file I can add these settings to instead.

It looks like I should be able to add an option (XkbOptions) to the inputdevice section of my xorg.conf, but when I tried this, the settings had no affect (perhaps gnome overrides the X settings?). I also tried adding a new inputclass to xorg.conf but that didn't work either.

What is the correct place to configure multiple keyboards with different key bindings?

share|improve this question
1  
Note: Putting this script in startup applications fixes it on login, but after resuming from suspend I have to run it manually again. There must be a better way to do this! –  psanford May 14 '11 at 20:53
    
There should be... I have been setting the default layout via /etc/default/keymap (Debian) or /etc/X11/xorg.conf.d/00-keyboard.conf (Fedora) to avoid the on-resume problem, but it may not work for multiple keyboards with different options (on both OSes, this is used to specify the console keymap as well as the X keymap, and thus is somewhat restricted). –  dhardy Feb 17 at 11:38
add comment

1 Answer 1

up vote 4 down vote accepted

It is possible to do this in the xorg config:

Section "InputClass"
  Identifier     "Keyboard Catch All"
  MatchUSBID     "058f:9410"
  Option         "XkbOptions" "caps:super,terminate:ctrl_alt_bksp"
EndSection

Section "InputClass"
  Identifier "Apple Keyboards"
  MatchUSBID     "05ac:0236"
  Option         "XkbOptions" "altwin:swap_lalt_lwin,caps:super"
EndSection

However, GDM has its own way of managing you keyboard settings that will overwrite these xorg settings. I have not found a solution that works well with GDM.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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