Problem: The Fn key on my Apple mini aluminium keyboard (wired) doesn’t work in Linux.
Solution, according to long Google research: the hid-apple
and usbhid
modules in recent kernel versions list the combination of properties of this keyboard so the kernel can support it properly.
Problem: I don’t want to recompile my entire kernel.
Solution: In the case of usbhid
, Ryan Finnie points out that the driver accepts keyboard properties configuration with an option, so I don’t need to recompile anything in the first place:
modprobe usbhid quirks=0x05ac:0x021d:0x00000800
Problem: In the case of hid-apple
, no handy option like that exists.
Solution: It’s only necessary to compile a newer version of that one module. Just nab a the latest hid-apple.c
and the latest hid-ids.h
form the kernel gitweb, and following instructions for compiling a single kernel module from Vivek Gite, stick them in a directory along with a Makefile
like so:
obj-m = hid-apple.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
Then you can just make
the module, and after that:
DRV=/lib/modules/$(uname -r)/kernel/drivers
mkdir $DRV/local # make a place for local drivers
cp hid-apple.ko $DRV/local/ # put ours in there
mv $DRV/hid/hid-apple.{k,x}o # disable the existing hid-apple.ko
depmod -a # rebuild module database
It may be necessary to do more than this depending on your distribution. I run Slackware, which doesn’t have introduce conventions of its own, so that was all I needed to do.
Problem: I’m running a mostly monolithic kernel, with which modprobe
fails for both usbhid
and hid-apple
. I need to boot a modular kernel. To do so I have to build an initrd with the right modules to boot. The only modules necessary are the ones needed to access the root filesystem; after that, the others can be loaded from there. I know I need a non-bog-standard SATA driver, and the ext3
module. But which driver(s)?
Solution: lspci -vv
reveals which drivers are used for which PCI devices.
Problem: I have ata_piix
in there, which does not correspond to any module, only to a ata_piix.c
in the kernel source tree; as well as PIIX_IDE
, which doesn’t even correspond to any file.
Solution: Grepping the kernel source for PIIX_IDE
reveals it’s in piix.c
. Along with ata_piix.c
, the two of them go into the directory alongside hid-apple.c
, and the first line in the Makefile
becomes
obj-m = piix.o ata_piix.o hid-apple.o
Same procedure as above follows to compile and install the lot.
Nearly done. Remaining steps:
-
Rebuild the initrd:
cd /boot && mkinitrd -c -k $(uname -r) -m ata_piix:piix:ext3
. Don’t forget to runlilo
to fix up the boot loader. -
Set up the right options to be passed automatically to the
usbhid
andhid-apple
modules when they’re loaded at boot: make/etc/modprobe.d/apple-mini-alu-kb.conf
with the following contents:options usbhid quirks=0x05ac:0x021d:0x00000800 options hid-apple fnmode=2
-
And for good measure, this is what I put in
~/.xinitrc
to map the keyboard the way I want it:setxkbmap -option '' -model apple us '' ctrl:nocaps altwin:meta_win altwin:swap_lalt_lwin
That will turn the Caps Lock into an extra Ctrl key, will make the Cmd keys work as Meta keys, and will swap the left Alt and Cmd/Meta keys. For some odd reason, it does not remove the
Mod4
modifier that belongs on the Cmd/Meta key from the Alt key, though, so it's necessary to follow this up with:xmodmap -e 'remove Mod4 = Alt_L'
Phew.
FIXME: remaining niggles:
hid-apple
apparently doesn’t get loaded at boot with the modular kernel