Thursday, May 19, 2011

Support for Aluminium Keyboards packaged, code-named apple-kbd

After many episodes, the support for Apple Aluminium Keyboards is finally becoming user-friendly. All major distribs now ship a recent version of xkeyboard-config, so there is no need to mess with XKB patches anymore...

To complete the user experience, I'm happy to introduce you apple-kbd, the collection of helpful goodies you need for your Aluminium Keyboard under Linux. Here's what you'll get with this package:

Automatic keyboard detection under X
At boot time or when the keyboard is plugged in, apple-kbd auto-updates the system-wide XKB settings so that the X server sees the Aluminium Keyboard and enables all its keys and its geometry.
Key style preferences
apple-kbd lets you remap some of the keyboard's keys: you'll get back the Insert key, the antique Print, Scroll-Lock and Pause... You can also set the precedence of functions keys over multimedia keys.
User-friendly installation
Both auto-detect and configuration features are available in a single, easy to install package. If you're running Debian or Ubuntu, there's even a package for you which comes with interactive configuration thanks to debconf!

Installing the debian package of apple-kbd

I made a PPA on Launchpad to package apple-kbd, so it's super easy to install it on your Debian or Ubuntu release. The plus of the Debian version compared to the plain sources is that you'll get a graphical dialog to configure your key style preferences. The dialog is also localized, only in French for the time being, but translators are welcome!

Automatic installation for Ubuntu Natty Narwhal

To install apple-kbd on Natty, you basically have to follow the instructions found on Launchpad. Just add the PPA to your list of available locations:

sudo add-apt-repository ppa:damien-ciabrini/apple-kbd

And once the PPA repository and its GPG key are imported, you can install the package as usual:

sudo apt-get update
sudo apt-get install apple-kbd

The first time you'll install the package, you'll be asked some questions regarding the behaviour of the keyboard, i.e., Insert key, PC keys emulation... At any time, you can reconfigure your keyboard by typing:

sudo dpkg-reconfigure apple-kbd

Manual installation for the others

Oh damned, you don't run Natty (like me...)! No worries, you can still proceed the Old Way™. Just edit /etc/apt/sources.list and add the following line at the end of the file:

deb http://ppa.launchpad.net/damien-ciabrini/apple-kbd/ubuntu natty main

And you're good to go! Resynchronize the index of available packages and install apple-kbd:

sudo apt-get update
sudo apt-get install apple-kbd

Don't want a Debian package? Get the sources!

The simplest way of getting the sources form GitHub is to download the latest apple-kbd archive:

wget --no-check-certificate https://github.com/dciabrin/apple-kbd/tarball/apple-kbd-0.1 -Oapple-kbd-0.1.tar.gz
tar zxvf apple-kbd-0.1.tar.gz

But you can of course fork my git repository to play with it:

git clone git://github.com/dciabrin/apple-kbd.git

Have a look at README.rst for the details. Basically, you want to edit the file apple-kbd to configure your keyboard preferences (Insert key, PC keyboard emulation...). Then, you need the usual:

make
sudo make install

I'm unfortunately a bit lazy, so contrary to the Debian package, you will need to reboot, or at least to re-plug the keyboard and restart the X server for your configuration to take effect. In a future version I will provide a command-line tool to force configuration changes to take effect on-the-fly.

Is the support finished?

I believe apple-kbd is really a milestone in the support of the Aluminium Keyboards. But of course, everything's perfectible. I actually see two important things that remain to do. The first one is to check whether the longstanding ISO-swapped-keys bug is really fixed for all the layouts. The second is to add a XKB geometry for the Wireless Aluminium Keyboards (the short ones). Plenty of work in perspective...

So here it is, tell the world about apple-kbd, future will tell if this package is useful!

8 comments:

ZenLord said...

Thank you for this - it installed perfectly on debian 6.0.

I chose to remap the Fn-key to insert, but my third-level-key doesn't work as a Fn-replacement. dpkg-reconfigure it is :)

Also the key left to the &1-key (showing #@) returns '<>' - I'm not sure if it is supposed to be this way (running on an Azerty BE-layout).

Another thank you! I will spread the word and patiently wait for an adaptation to use for the wireless keyboard ;)

Unknown said...

Hi ZenLord, glad to hear that it works for you :)

The trouble with '<>' is a known issue, XKB settings re-use mapping from old mac keyboards, which do not fit perfectly with newer Aluminium Keyboards.

I'm working on a solution for the 16 or 17 available layouts, stay tuned!

Cheers

Pierre said...

Paramétrage de apple-kbd (0.1-0ubuntu1) ...
Error loading new keyboard description
dpkg : erreur de traitement de apple-kbd (--configure) :
le sous-processus script post-installation installé a retourné une erreur de sortie d'état 251
Des erreurs ont été rencontrées pendant l'exécution :
apple-kbd
E: Sub-process /usr/bin/dpkg returned an error code (1)
famille@famille:/sys/module/hid_apple/parameters$

Unknown said...

Pierre,

Peux tu me dire le nom de ta distrib ? Que je puisse regarder ce qui ne fonctionne pas.

Roman S said...

Hi! I have a strange problem with my usb keyboard. My Ubuntu 11.04 won`t boot up when it`s pluged in. Although it works perfectly on Windows. I suspect xorg to be the problem, but I`m not sure.

Unknown said...

Thanks for your job and sharing it, very useful.

One suggestion for improvement, do you think you can add support for "Meta - Alt" swapping? Something like:
RUN+="/lib/udev/keymap $name /etc/udev/keymaps/apple"
with 'apple' something like

0x700E2 leftmeta
0x700E3 leftalt

Unknown said...

Hi Christophe,

It's part of a yet unpublished round of patches which aim at complete apple layout support, including providing perfect layouts for all languages.

I hope to be able to provide patches to Xorg in the coming weeks.

Thanks for your time :)

Blake said...

Came across your blog posts on the apple aluminum keyboard, and they have been a revelation. Thanks for all the hard work.

I'm working on Linux Mint Debian Edition 201303.

I've attempted to install apple-kbd through your ppa, but have been unable to do so. Actually, "apt-get update" is unable to connect to your ppa. I downloaded the .deb package and attempted to install through gdebi, (and apt-get), but get the following error message:

Selecting previously unselected package apple-kbd.
(Reading database ... 248150 files and directories currently installed.)
Unpacking apple-kbd (from .../apple-kbd_0.1-0ubuntu1_all.deb) ...
Setting up apple-kbd (0.1-0ubuntu1) ...
Fontconfig warning: "/etc/fonts/conf.d/53-monospace-lcd-filter.conf", line 10: Having multiple values in isn't supported and may not work as expected
Error loading new keyboard description
dpkg: error processing apple-kbd (--install):
subprocess installed post-installation script returned error exit status 251
Errors were encountered while processing:
apple-kbd

This was after I had originally applied your patch from your 2009 post. I hadn't gone back to undo the changes made by applying that patch, so if that mucked up the process, I apologize for my subpar knowledge of keyboard mapping.

Do you have an idea where I might start trying to fix this? I currently have only the left shift key, no up/down arrows, and no numpad -- it's been slow going to say the least. Thanks!