I'm on Ubuntu trusty, and I use greek letters for algebra. I'd love to be able to type them in quickly with AltGr-letterKey.

For example, map alpha to AltGr-A, map beta to AltGr-B, map theta to AltGr-T, etc.

This page explains how to do it on an earlier version of Ubuntu. When I try following it, I can go to System Settings -> Keyboard -> Typing -> Compose Key.

But when I get to Compose Key, it says that it's 'disabled'. Nothing happens when I click the row and hold down new keys, nor when I press backspace to clear. Even if it did work, I don't see how that would enable to me to re-assign AltGr-[A..Z].

Can anyone help?

This is a long answer. If you want a TL;DR version --- xmodmap is sort-of deprecated; layout switches will reset it; go to the section called "and finally, I did it" at the end for my solution.

I suppose you have your AltGr-something working already. It will depend on your keyboard configuration to have it activated or not. On my PCs, it works with Spanish and US-International but NOT on plain US keyboard.

The method I use is with xmodmap, but it works only partially: if it works or not will depend on your layout and even then it will be reset every time you change layout. See later for the "real" (but complex) solution.

You can use xmodmap by following these steps:

1) In a terminal issue

xmodmap -pke > mykeydefs.lst

(extension and name free --- use what you like)

2) edit the file; you will see a bunch of lines like...

keycode   8 =
keycode   9 = Escape NoSymbol Escape
keycode  10 = 1 exclam 1 exclam bar exclamdown
keycode  11 = 2 quotedbl 2 at at oneeighth
keycode  12 = 3 periodcentered 3 numbersign numbersign sterling

These are your keyboard definitions. Find for example the entry for A:

keycode  38 = a A a A ae AE

This means that pressing this key you have "a", shift+key "A", etc... the interesting ones are the 5th and 6th (1), which are normally associated to ALtGr and Shift+AltGR. Pressing AltGR + A you should have the symbol "æ".

If you have more than 6 entries, try to see which ones are activate by your AltGR combination: for example, if you have

keycode  38 = a A a A ae AE aring Aring

and you have an å when pressing AltGr-A, the entry to modify will be the 7th and 8th...

3) change the line to

keycode  38 = a A a A Greek_alpha Greek_ALPHA

(capitalization is important). You can edit all the lines you want; it is better if you delete all the lines you left untouched. The list of all the symbols is here, but take into account that if they are visible or not depend on the font you are using, too. Save the file.

4) Reload the new mapping

xmodmap mykeydefs.lst

This command must be silent --- if it shows any error, the map is not loaded.

5) test it. Now pressing AltGr + a should give the symbol alpha (well, alpha letter greek in Unicode, really).

6) if it works, you can set the command in the list of your startup commands.

The real solution (hints at it, at least)

If the xmodmap method does not work, you'll need to edit your keyboard layout. I have found some interesting links:

  1. An howto and a thread on creating your own keyboard layout.

  2. A quite complete guide to the XKB system.

  3. A blog entry on making local modifications to your layout.

And finally, I did it:

  1. A little example of a direct modification to the system files (I could not find how to do that in your local ~/.xkb directory).

  2. A nice configuration to have all the greek letters with a single modifier.


Footnotes:

(1) by the way, in all manuals and instructions around it is said the "mode_shift" chars should be the third and the fourth. Which on Ubuntu are not, and I can't really find any documentation with details. If anyone can point it to me, I will be grateful.

  • thanks for such a detailed reply! I tried that and sadly it didn't work - I think the mapping in mykeydefs.lst isn't the one that's used by the OS for interpreting keyboard input. eg in I now have keycode 38 = a A a A Greek_alpha Agrave Acircumflex but AltGr-A types in å. In system settings -> Keyboard -> Layout Settings, Input sources to use is set to English (UK, extended WinKeys). Do I need to modify the input source to something else? – Alexandre Holden Daly Feb 19 '14 at 18:14
  • Hmmm... you have more than six entries for the key? This is quite strange. Do you have any output/error when you load the new map with xmodmap? I have checked with my spanish keyboard, but will double check at home with an US-international keyboard. What is the output of "xmodmap" (w/o options)? – Rmano Feb 19 '14 at 19:01
  • thanks a lot for the help. the output is xmodmap: up to 4 keys per modifier, (keycodes in parentheses): shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x42) control Control_L (0x25), Control_R (0x69) mod1 Alt_L (0x40), Meta_L (0xcd) mod2 Num_Lock (0x4d) mod3 mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf) mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb) – Alexandre Holden Daly Feb 20 '14 at 18:51
  • (that doesn't look very clear.. if you want I can copy that output again with a |< sign to tell you when it's new line) – Alexandre Holden Daly Feb 20 '14 at 18:52
  • ...it's the same than mine. I suppose you will need to define your own layout... the link is: ubuntuforums.org/showthread.php?t=188761 (seems that xmodmap works only by accident!) – Rmano Feb 20 '14 at 18:56

Enable Compose Key in dconf-editor to set up AltGr

Within dconf-editor go to org>gnome>desktop>input sources. Edit the entry xkb-options to set the Compose Key you wish, such as ['compose:ralt'].

This earlier answer includes terminal commands as well: Make "super/window" as compose key in Ubuntub

Using Compose Key will give you lots of additional characters quickly but Greek letters are not included without additional keystrokes.

For quick access to Greek letters use IBus to switch between your usual keyboard layout and the Greek alphabet. IBus may appear in your main menu as "Keyboard Input Methods". You can install it with sudo apt-get install ibus.

After you start IBus add the "Greek, Modern" layout under the "Input Method" tab. In the "General" tab you'll find the method to quickly switch keyboard layout. In my case it's Win+Space. By pressing that combination you immediately switch to Greek layout and pressing a gives α (alpha).

With this method you stay with Greek until you switch back to your home layout with Win+Space.

  • thanks! very newbie-ish question, but how do I navigate to org? I can't find it in /, and find / -name org returns a lot of paths. – Alexandre Holden Daly Feb 18 '14 at 18:06
  • @AlexandreHoldenDaly Sorry, "org>gnome>desktop>input sources" are within dconf-editor, they aren't directories on the computer. – Sean Feb 18 '14 at 20:08
  • thanks again. when I get to xkb-options its value is set to []. When I click on [] it lets me edit it. substituting it for compose:ralt doesn't work, but ['compose:ralt'] does. What does this do though? How do I map eg AltGr-A to alpha? – Alexandre Holden Daly Feb 19 '14 at 10:26
  • @AlexandreHoldenDaly Sorry was focused on "AltGr" instead of your ultimate goal. I've revised answer with this in mind. – Sean Feb 19 '14 at 16:12
  • τhαnκ γou, τhατ's preττγ gooδ! I don't actually want to type in greek though, I use greeks for maths so I need to be able to change as quickly as possible from greek to latin. But at least it's working. Thanks a lot for your help! – Alexandre Holden Daly Feb 19 '14 at 18:28

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.