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:
An howto and a thread on creating your own keyboard layout.
A quite complete guide to the XKB system.
A blog entry on making local modifications to your layout.
And finally, I did it:
A little example of a direct modification to the system files (I could not find how to do that in your local ~/.xkb
directory).
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.
Best Answer
Alt_Gr has the very intuitive name
ISO_Level3_Shift
. Therefore one has to change the following line in thepc
file as instructed here fromto