The Apple aluminium keyboards are very nice. I recently bought one for an Ubuntu Linux machine, and it requires some special configuration to work as expected.
This post describes how to fix the function keys and swap command (windows or ‘super’) keys with the alt (or option) keys.
The new modprobe/hid_apple way
The following commands will alter the parameters for the hid_apple module and then reload the module. You must run them as root.
# echo options hid_apple fnmode=2 swap_opt_cmd=1 > /etc/modprobe.d/hid_apple.conf # rmmod hid_apple && modprobe hid_apple
The old xmodmap way
UPDATE 2014-11-11 – On new kernels you really should use the method above! It’s much better, you can use both Apple and non-Apple keyboards at the same time for example.
This command will fix the function keys, it saves you pressing fn-F1 whenever you want F1. The first command is for older kernels, the second is for version 2.6.28 or later.
# echo 2 > /sys/module/hid/parameters/pb_fnmode # echo 2 > /sys/module/hid_apple/parameters/fnmode
Then add that line to your /etc/rc.local file, somewhere before the exit 0 at the end, so that it gets run on startup.
Next to swap the Command/Alt keys using xmodmap. I’m aware you can do this from the Gnome Keyboard Settings panel, but I’ve found this method works better. Particularly when combined with synergy.
Create a file called ~/.xmodmaprc with this inside:
clear mod1 clear mod4 keycode 133 = Alt_L keycode 134 = Alt_R keycode 64 = Super_L keycode 108 = Super_R add mod1 = Alt_L Alt_R add mod4 = Super_L Super_R
Now run to activate the new keys, run:
$ xmodmap ~/.xmodmaprc
Don’t forget to add it to your list of startup programs. If you’re using Gnome, look at System->Preferences->Startup Applications
Otherwise you can just add it to ~/.xsession
To find the keycodes above I used the xev program. Try running it from a console. It shows you all X11 events that the xev window receives, including key presses/releases.