Category Archives: Macintosh

Apple keyboards with Linux

PPC - How I Got the Left Side of My Keyboard Back

Warning: For the most part this post is not relevant anymore. I don’t have an Apple computer anymore so siphon through it as best as you and if you let me know the details, I’ll update it.

After a year of cramping, odd hand contortions, I finally got my Apple keyboard to behave as I’d like. Apple uses hardware/firmware that alters the behavior of the standard keyboard (e.g. remapping F1 to brightness down, assigning the Apple key…). Prior to 2000 used the Apple Desktop Bus (ADB) now I believe it uses the firmware to alter the default behavior of select keys. Here’s what you can do to adapt your Apple keyboard to more standard behavior.

Problems FN’ing

“The Mac’s keyboard layout is a little different from a standard PC one.”[1]

Adapting to the ADB keyboard’s layout can take time to acquire for the regular Windows or Linux users, but isn’t necessary. For the F1-F6 function keys the behavior can be altered.

For older new age Macs that use ADB, the powerbook buttons daemon (pbbuttonsd) can do this (most PPC distros already have this installed). You’ll need to edit ‘/etc/pbbuttonsd.conf’ to configure it. Alternative you might be able to use the graphical client gtkpbbuttons. For newer macs install pommed to get normal function key behavior back.

X got Served

The standard layout now days is pc105, you can put it in your xorg configuration file (/etc/X11/xorg.conf) like this (this though likely isn’t necessary as evdev does a good job of detecting devices and language):

Section "InputDevice"
    Identifier  "Generic Keyboard"
    Driver      "kbd"
    Option      "XkbRules"  "xorg"
    Option      "XkbModel"  "pc105"
    Option      "XkbLayout" "us"

For Old World Macs you might want to consider using “macintosh” instead of “pc105”.

Remap Command Keys

For the remapping special keys (Control, Alt, Apple, Caps…), I’ve seen many people use xmodmad (discussed in next section). Xmodmap is a good program but it can be quirky at times. A better way to specify these keys is in the xorg server configuration file.

The X server has a list of known keyboard mappings in /usr/share/X11/xkb/rules/xorg.lst. From there you can, for example, map the Control key to the Apple key:

Section "InputDevice"
    Identifier  "Generic Keyboard"
    Driver      "kbd"
    Option      "XkbRules"   "xorg"
    Option      "XkbModel"   "pc105"
    Option      "XkbLayout"  "us"
    Option      "XkbOptions" "altwin:ctrl

Mapping Unknown Multimedia Keys

All brightness, volume keys… should work if mapped to the Xservers corresponding values: XF86BrightnessAdjust, XF86AudioLowerVolume, XF86AudioRaiseVolume, XF86AudioMute… Use xev to discover if these values are correct and set the appropriate keymap.

Other Key Mappings

You can create a special ~/.xmodmap that will load when xmodmap does but I found that it can sometimes be bugggy. Xmodmap works better directly through the program and then writting bash script to repeat these actions. Remapping keys with xmodmap can be done by:

xmodmap -e 'keycode 115 = Control_L'

Where “keycode 115” is the key to map to left control key. Xmodmap can change, replace or swap just about all keybindings. Remapping may not be enough though and may work better if conflicting bindings are first removed and then reset:

xmodmap -e 'remove control = Control_L'
xmodmap -e 'keycode 115 = Control_L'
xmodmap -e 'add control = Control_L'

Eventually though some program might try to define it’s own keymappings and the xmodmap settings wil be lost. This is where xkbset comes in. It takes away the expiration values for keymappings.

xkbset exp m

The exp argument turns expiration off. Put this in a bash script and add it to startup and the keys will be remapped.

Gnome Quirks

Warning: This may be an old bug and not relevant anymore.

Gnome shouldn’t have anything to do with keyboard settings. Be sure you got your setup correct (language and keyboard) and Gnome should use these values. Occasionally errors can occur though if you change your keyboard settings from within Gnome. If you get errors like:

The X system keyboard settings differ from your current GNOME keyboard settings

Deleting Gnome’s keyboard gconf settings should fix the problem:

rm -r ~/.gconf/desktop/gnome/peripherals/keyboard/kbd/


Though xev displayed that XF86AudioRaiseVolume, XF86AudioMute were mapped correctly, Gnome failed to be able to connect to them (be sure Gnome Power Manager is installed first). This is likely an issue with ADB. Going to “Keyboard Shortcuts” and re-entering the values does work, but it’s easy just to create a script and load it on boot:


gconftool-2 --type string --set /apps/gnome_settings_daemon/keybindings/volume_down XF86AudioLowerVolume
gconftool-2 --type string --set /apps/gnome_settings_daemon/keybindings/volume_up XF86AudioRaiseVolume
gconftool-2 --type string --set /apps/gnome_settings_daemon/keybindings/volume_mute XF86AudioMute


Warning: This section is dated and may not work anymore.

In Linux, key mappings are initially loaded for console with an init script. The script uses the loadkeys program to bind a new keymapping. By default many distrobutions and architechtures use the i386 profile console keymappings. Most keyboards are alike so this is acceptable, but obviously this mapping doesn’t have support for ADB keys. Macintosh keymaps are available but I’ve tried them and they are either depracated or for Old World Macs.

Keymaps are stored in /usr/share/keymaps, and are set using KEYMAP="us" or KEYMAP="ru-win" in the /etc/conf.d/keymaps init script configuration file. To test a keymap:

loadkeys us
loadkeys uk

Test and pick a keymap that has the highest number of correct key mappings for the keyboard.

Warning: Don’t change /etc/conf.d/keymaps and restart the init script (/etc/init.d/keymaps) if the X server is running! It’s best to work from console with no X server running.

When a good keymap is found print it to file it so it can be edited.

dumpkeys > /etc/default.kmap

The program showkeys can be used to get the keycodes. For my computer I had to find the values of function keys F1-F6 when fucntion is both on and off.

    Off   On
F1  59    224
F2  60    225
F3  61    114
F4  62    115
F5  63    reserved num-lock
F6  64    113

For each of the keys I switched all instances of their keycodes in /etc/default.kmap. I also added Control to the Apple key:

Keycode 125 = Control

Finish by referencing the new keymap to the KEYMAP variable in /etc/conf.d/keymaps. The keymaps boot script or the system will need to be restarted.

Howdy and hello!

Well this is it my new site! Perhaps the first thing I will do is to thank you for visiting. I can definitely say that I am happy setting up this blog on WordPress. Well Done, WordPress!

A little about me. I like to discover, try and check out new programs. Linux is a great OS for this. Lately I’ve been playing games and I just added the Darwinia page that is worth checking out. This is a rare game on Linux that runs very well even on slightly dated hardware. It’s more of a how to as I had a little trouble setting it up (at least with the mods.)

I also put on my iBook Linux which is neat, and a heck of a lot of fun. If you have an older desktop you can resurrect it with Linux. I actually did this install several months (January?) but I updated it and still think it’s pretty worth it (Mac OS 9 is kinda dated, and I still love it, but it need a few things).