Introduction

macmini-w-vBox-s200.png

In discussions on Ubuntu forums there seems to be lack of interest and/or understanding of what it means that Apple keyboards are not properly managed by Ubuntu, and that the problem is getting worse with every new release. Beside the fact that almost all releases of Ubuntu since 8.04 (Hardy Heron) introduce new variations of managing the Apple keyboards, there is a great deal of confusion whether this is an Apple related issue or a general Ubuntu installation and maintenance issue.

my-amd-n-AppleKBD-w-vBox-s200c-h.png

In fact this becomes a much broader problem when virtual machines such as VirtualBox are considered.



The reason I decided to write this document was the point, that this is not merely an Apple related Ubuntu installation and configuration problem. Though I discovered the potential that the problem with Apple keyboards with newer Ubuntu releases may spread even to non-Apple platforms. Unlike on regular and home built PCs on Apple machines, the scare or urgency is not so eminent and immediate since one can always get Apple keyboard working with the help of <fn> key. Nevertheless, it would be nice to have this fixed in Ubuntu installed on Apple platforms too. As you can see this is a rather obscure but very complex multilevel problem. Needless to say, the <fn> key on non-Apple platforms will not work. Let us first try to separate all the different circumstances in which this problem exists.

Separation of issues

  1. Running Ubuntu on non-Apple hardware without Apple keyboard
  2. Running Ubuntu on non-Apple hardware with Apple keyboard
  3. Running Ubuntu as VM on a PC without Apple keyboard
  4. Running Ubuntu as VM on a PC with Apple keyboard
  5. Running Ubuntu on Apple hardware
  6. Running Ubuntu on Apple hardware as VM on a PC with Apple keyboard

For all of the items in the above list, we have a different circumstance, and potentially a problematic behaviour in all but items 1 and 3.



All these different situations should be managed in a single place and that place should always exist unconditionally, which is now not the case, and of course is the crux of the problem. In order to understand this single place a short description is in order.


Apple Keyboard Configuration On Apple

For some time in Ubuntu we have now been used to fix the problems with function keys on aluminum Apple Keyboard, by adding the following command into the /etc/rc.local:

echo 2 > /sys/module/hid_apple/parameters/fnmode

As you can see this /etc/rc.local line writes "2" to the fnmode special file. In Ubuntu Help Wiki page: (AppleKeyboard) we can learn that the value in the fnmode special file can have three different values:

  • 0 = disabled : Disable the fn key. Pressing <fn+F8> will behave like you only press F8

  • 1 = f-keys last : Function keys are used as last key. Pressing F8 key will act as a special key. Pressing <fn+F8> will behave like a F8.

  • 2 = f-keys first : Function keys are used as first key. Pressing F8 key will behave like a F8. Pressing <fn+F8> will act as special key (play/pause).

Special Unix Files And Direcrories a.k.a. Logical Disks

On Unix (Linux) systems logical disks represent a storage abstraction that kernel sees as a linear sequence of fixed sized random acessible blocks. These structures appear in Unix directory tree as if they were regular directories and files. However, they are not they can not be created by simple means such as editors even by root. These special files if they exist can, however, be written to bt superuser. Indeed, such a special file is our fnmode. In fact, all the files under the directory /sys are these special files. Relevant to our discussion is the branch under /sys/module/hid_apple

Special Files Required For Apple

Following is the branch /sys/module/hid_apple

/sys/module/hid_apple
/sys/module/hid_apple/drivers
/sys/module/hid_apple/drivers/hid:apple
/sys/module/hid_apple/holders
/sys/module/hid_apple/initstate
/sys/module/hid_apple/notes
/sys/module/hid_apple/notes/.note.gnu.build-id
/sys/module/hid_apple/parameters
/sys/module/hid_apple/parameters/fnmode
/sys/module/hid_apple/parameters/iso_layout
/sys/module/hid_apple/refcnt
/sys/module/hid_apple/sections
/sys/module/hid_apple/sections/.data
/sys/module/hid_apple/sections/.exit.text
/sys/module/hid_apple/sections/.gnu.linkonce.this_module
/sys/module/hid_apple/sections/.init.text
/sys/module/hid_apple/sections/__mcount_loc
/sys/module/hid_apple/sections/.note.gnu.build-id
/sys/module/hid_apple/sections/__param
/sys/module/hid_apple/sections/.rodata
/sys/module/hid_apple/sections/.rodata.str1.1
/sys/module/hid_apple/sections/.rodata.str1.8
/sys/module/hid_apple/sections/.smp_locks
/sys/module/hid_apple/sections/.strtab
/sys/module/hid_apple/sections/.symtab
/sys/module/hid_apple/sections/.text
/sys/module/hid_apple/srcversion

And here is the long listing of the directory with our fnmode file:

$ ls -l /sys/module/hid_apple/parameters
total 0
-rw-r--r-- 1 root root 4096 2011-12-21 15:59 fnmode
-rw-r--r-- 1 root root 4096 2011-12-27 12:04 iso_layout


What Is a Problem

apple-aluminium-kbd-s300.png

Now that we have the terminology under control and understand what we are talking about perhaps we should again look into at the Ubuntu Help Wiki page AppleKeyboard to see what in this area should be simplified in the future releases.

It is obvious that kernel manages Apple keyboards based on the parameters found in special files. As reported in Ubuntu forums these special files in some circumstances, especially in Ubuntu 11.10, get corrupted, reset themselves or disappear overriding what user specified in /etc/rc.local, or worse, do not exist at all in VMs.

If a user incorrectly uses instructions in AppleKeyboard, they can destroy branches and/or files in the Special Unix files infrastructure. The trouble is that in VMs and poerhaps even in non-VM environments none of the actions described in forementioned Ubuntu Wiki help file fix the Apple keyboard problem.

For regular users it is hard to test all these environments systematically, but my large fear is that upgrading from 10.10 to current releases (11.10) or later will introduce this problem also in places where now there is no problem.

TroubleWithAppleKbdOnUbuntu (last edited 2011-12-28 22:12:20 by iggi)