Fixing the cmd and fn keys with an apple keyboard in linux
I use an apple keyboard at work, I also use ubuntu. There are two things that I need to do to fix the cmd and fn keys with an apple keyboard in linux.
1) modify a file to make the F1-F12 keys work properly (eg, pressing the fn key makes the play, volume buttons, etc work)
The way I get this to work is: (from the ubuntu page here: https://help.ubuntu.com/community/AppleKeyboard)
modify /etc/modprobe.d/hid_apple.conf creating it if necessary:
regenerate initramfs bootfile.
echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf sudo update-initramfs -u -k all sudo init 6
2) setting the keyboard to be a mac keyboard and making the cmd key behave like the ctrl key.
Firstly, I select a mac keyboard fromt he keyboard setting in system preferences, then I modify the keys. For this, I create a shell script, with the following content:
#!/bin/sh setxkbmap -variant mac -layout gb -option altwin:ctrl_win
I drop that in ~/bin and chmod +x it.
I then add it to my startup items (I use gnome-shell, so I add it using gnome-tweak-tool)