17

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?

psanford
  • 436

1 Answers1

9

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.

psanford
  • 436