Sunday, October 23, 2011

Apple keyboard on FreeBSD

Recently I bought an iBook G4 just for fun and of course installed FreeBSD on it. Installation goes pretty smooth starting with 9.0: I've started with 9.0-BETA3 and later updated to 10-CURRENT. I used it as a toy mostly but on Thursday my main laptop (which also runs FreeBSD, but amd64/8-STABLE) died and I had to use iBook as my main system and some problems became noticable.

There are two annoying problems with Apple keyboards:

1. Function keys (F1, F2, ...) work as they supposed to work only when pressing them with FN key. I rely on virtual desktops a lot and I use Ctrl-Fx to switch between them, so you imagine how annoying is that to use Ctrl-Fn-Fx to switch a desktop.

2. Apple keyboard misses 'Insert' key completely, so you cannot use Ctrl-Insert for pasting, so it's extremely annoying also.

Fortunately, both problems could be easily solved.

Several days ago Nathan Whitehorn ⟨nwhitehorn@) committed a support for dev.akbd.%d.fn_keys_function_as_primary which allows you to configure F-keys behavior. In order to make the keys look as F1,F2,... without pressing FN, execute:
sysctl dev.akbd.0.fn_keys_function_as_primary=1

The Insert key problem could be solved on X level: I've used xmodmap (x11/xmodmap) to remap F11 to Insert, which is a good solution for me because I don't use F11 key and it's located quite close to a place where you'd expect to have 'Insert' key on a typical keyboard.

So I've created ~/.Xmodmap file:
keycode 95 = Insert

And added execution of "xmodmap ~/.Xmodmap" on X session start.

I'm not sure if F11 has keycode 95 on every Apple keyboard, it's easy to figure out keycode using xev (x11/xev).


  1. yeah
    the same as me but mine is dell which there is no Scroll Lock key

    many thanks indeed

  2. I have an USB Apple Aluminium Keyboard, the F-keys work normally, but I wonder how to use F13-F19 (xev doesn't react to them at all)…

  3. lapo, I don't have such a keyboard. You might want to post a question to freebsd-powerpc@ maillist. I think it's akbd driver related, not to X.

  4. nice idea, thanks for sharing

    our websites are
    徵信社 and 櫻桃

    very welcome to see us