Ubuntu: Map AltGr-[a..z] and Shift-AltGr-[A..Z] to greek letter



Question:

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?


Solution:1

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.


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »