Sean's Musings as a Service

Sean's Musings as a Service

Getting my little Apple keyboard to not suck at life with Ubuntu

  • Published:
  • categories: linux
  • tags: apple-keyboard, linux, shortuts, ubuntu, xev, xmacrokeys, xmodmap

Good news is that many of the old issues that happened with older versions of Ubuntu are fixed. But my wishlist keeps getting bigger for this little beast. Here is what I set out to do:

  1. Add a delete button, I mean a real delete button, since “delete” in Apple-land is really backspace to the rest of us?
  2. Get the “fn” key working,I don’t like non-functional buttons taking up my valuable corner real estate.
  3. Add Page Up and Page Down, something like fn + Down and fn + Up, like on some laptops.
  4. Add Home and End keys, these are something I didn’t realize I would miss, that is until I started missing them…

So I started doing some reading up on how the heck to do this, looks pretty straight forward but the information is scattered in bits and pieces all over the nets. So after my obligatory reading so I don’t feel like a copy-paste monkey I start trying this. And very quickly I realize that I am not understanding this well enough yet, then I stumbled across this:

What’s the format of a “keycode-line”?

(i.e. the result of xmodmap -pke or Suns xmakemap)

keycode <x> = <1> <2> <3> <4> <5> <6> <7> <8>

Only the first four elements are platform-independent and of real interest (see below about the last four) :

Solaris Openwin 3.5 (X11R5), Type-5 US keyboard     <strong><1>                           <key>     <2>                     <shift-key>     <3>             <"Mode_switch"-key>     <4>       <shift-"Mode_switch"-key></strong>     <5>                <"Num_Lock"-key>     <6>               -     <7>  <"Num_Lock"-"Mode_switch"-key>     <8>               -

Look at positions 1-4: There are two groups, each with two keys. You get the 2nd group with ‘Mode_shift’/AltGr and the second key in each group with ‘Shift’.

The fastest way, concerning typing, to get special (e.g. latin1) characters on US/EN Keyboards is to use “Mode_switch”: For this purpose you have to map the KeySym Mode_switch onto a keycode of your choice and map it to an arbitrary, still available logical modifier, called mod1-5, see below You certainly also have to provide the KeySyms for the wanted special characters, you will usually put them in the second group, i.e. the 3rd and 4th position.

(XFree86 usually doesn’t require the explicit mapping as modifier. This shall apparently ease the configuring. But it’s not possible to refrain from modifiers in general.)

In contrast, the “Multi_key/Compose” mechanism doesn’t need to be also mapped as modifier and is easier to configure, but you’ll have to type more then - and not all applications support it. However older X11R5 Xservers do it completely Xserver internally, then it works always.

( Only for the sake of completeness: If only a single key is defined in a group [certainly only possible with the last in a complete row], then it’s a shorthand for a complete pair of a KeySym-name in small and CAPS. )

-  Sven Mascheck (1) With this I had a better understanding of what I was doing and how X was going to get my input,

Adding a delete button:

So I don’t normally “need” delete, but since I am using VMWare server and I remote console to my various Windows machines all day, I inevitably need to hit Ctrl+Alt+Del to login to some of these puppies. This one is is pretty easy from the X stand point, I picked one of the Apple keys, in my case the left Command button. So I fire up xev and hit the left command button, keycode 133 it is.

Getting the “fn” key to work

So the internets said, I could get this to work I think…

# echo 2 > /sys/module/hid/parameters/pb_fnmode# echo 2 > /sys/module/hid_apple/parameters/fnmode
# echo 2 > /sys/modules/hid_apple/parameters/fnmode