2 Irish-friendly keyboard layout for an Apple aluminium USB keyboard on Ubuntu

Jan 18th, 2011   3:07 am

By default, Ubuntu has plenty of Irish keyboard layouts which will let you type a fada on your vowels. However, if you’re using an Apple aluminium USB keyboard, like me, your layout options are restricted. I have the UK variant of the keyboard, which does have a corresponding layout in Ubuntu (under United Kingdom > Macintosh), but that doesn’t provide support fadas (acute accents).

My goal was to have Shift+2 give me @, AltGr+2 give me €, Shift+3 give me # and AltGr+3 give me £. Also, of course, the fadas to work on any vowel (including Shift support for upper case). To do this I appended a variant to the end of the existing Ireland “symbols” file, as follows:

  1. As root, edit /usr/share/X11/xkb/symbols/ie. Older versions of Ubuntu (earlier than 8, I think), has a different file path.
  2. At the end of the file, append the following:
    partial alphanumeric_keys
    xkb_symbols "macie" {
    	// Fix currency symbols, # symbol and 'fada' support.
    	include "latin"
    	name[Group1]= "Ireland - Macintosh";
    	// Numeric Row 123456789
    	key <AE02> { [ 2, at, EuroSign ] };
    	//key <AE03> { [ 3, sterling, numbersign ] };
    	key <AE03> { [ 3, numbersign, sterling ] };
    	// Top Row QWERTYUIOP
    	key <AD03> { [ e, E, eacute, Eacute ] };
    	key <AD07> { [ u, U, uacute, Uacute ] };
    	key <AD08> { [ i, I, iacute, Iacute ] };
    	key <AD09> { [ o, O, oacute, Oacute ] };
    	// Middle Row ASDFGHJKL
    	key <AC01> { [ a, A, aacute, Aacute ] };
    	include "level3(ralt_switch)"
    };
    

    You’ll see a comment line for the more accurate keyboard mapping of Shift+3 giving the £ symbol (to closer match the printing on the keys of a UK Apple keyboard). However, I prefer Shift+3 to give # as I’m a programmer; feel free to choose whichever you want (and comment/uncomment as appropriate). Save the file.

  3. Then, you edit /usr/share/X11/xkb/rules/evdev.xml to configure your new variant. Search for Ireland, and you’ll see it has a <variantList> with a bunch of <variant> nodes. You want to add the following XML as a new <variant> node at the end of the others, and before the closing </variantList> tag.
     <variant>
    	<configItem>
    		<name>macie</name>
    		<description>Macintosh</description>
    	</configItem>
    </variant>
    
  4. Finally, to start using your new custom layout, go to System > Preferences > Keyboard (on a Gnome desktop) and, on the Layouts tab, you can add your new custom layout. Select “Ireland” as the country and you should see the new “Ireland Macintosh” layout. You can set the layout priority by moving the new layout up/down the list, or remove any others if you just want the one layout.

So there’s a quick way to get fadas and currency symbols working for your Apple UK USB keyboard on Ubuntu.


UPDATE: Added missing closing XML tags for name/description in snippet above, and fix tag angle bracket mushing by WordPress.


UPDATE2: For Ubuntu 14.04 (using Unity, rather than the Gnome desktop), the same steps 1 to 3, above, apply. To apply your custom layout, you can launch the Dash, and search for “Text Entry”. From there you can add the new layout (the plus symbol, bottom left). Here are three tips if you don’t see your custom layout, or if it doesn’t work as expected when you switch to it:

  1. If the custom layout doesn’t appear in the list of available layouts, you might need to allow custom layouts. Using dconf-editor (sudo apt-get install dconf-editor if you need to install it): Navigate to org/gnome/libgnomekbd/desktop and enable the load-extra-items checkbox. Now, close your Keyboard / Text Entry preference panel, and launch it again. Your custom layout should now be available.
  2. If you have added the custom layout, and you have switched to it, but it is still not behaving, deleting the xkb cache: sudo rm /var/lib/xkb/*.xkm
  3. If you still have no joy, try logging out and back in; or rebooting entirely.

Comments:

Langer Dan
Jan 18th, 2011   9:03 am

Thanks for that. I've got exactly same combo of Ubuntu and Mac aluminium keyboard, but never worked up the energy to solve it properly. Getting this patch into Ubuntu permanently would be nice. Now if we could just get Open Office to stop calling us Éire in English translation I'd be all set.
Keith
Sep 1st, 2012   6:03 pm

Great post. I've included this so that the tilde symbol maps on my MacBook. key { [ grave, asciitilde ] }; Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php