How do I input Greek characters in Ubuntu?

If you just want to enter a couple a Greek characters, I would find their Unicode character number and use Unicode composition.

For example:

U+03D0 GREEK BETA SYMBOL
Ctrl+Shift+u+0+3+d+0+<Enter>
ϐ

Σιμπλζ αδδ τηε Γρεεκ λαζοθτ το ζοθρ Κεζβοαρδ λαζοθτ πρεφερενψεσ. Τηεν αδδ τηε Κεζβοαρδ Ινδιψατορ αππλετ το ονε οφ ζοθρ παλελσ ανδ θσε τηατ το σςιτη λαζοθτσ.

Simply add the Greek layout to your keyboard layouts. Then add the "Keyboard Indicator" applet to one of your panels and use that to switch between layouts. It seems to work for me.

Edit:

Changing the layout via a key combination seems to be a bit flaky:

Choose "Layout options" in the Keyboard preferences dialog and find the group of options labled "Keys to change layout". You will then simply have to try the different options and see which one works for you, both on a system level and a usability level. I guess for the option that says "both alt keys" you will need two Alt keys (I have only one here). On the other hand, I definitely have to Ctrl keys, but the "Both Ctrl keys" option doesn't work for me either.

I understand that you want to avoid cluttering your panel, but my guess is that you will need some sort of indicator of the current layout or you'll find yourself constantly typing in the wrong one. Of course, your mileage may vary.


If you just want a few Greek characters (e.g., for math equations), then I highly recommend using XCompose. Here is how.

1. Find your dead_greek key (or define one)

By default, XCompose is configured to use a special <dead_greek> key. You can check what is your <dead_greek> key by running the following command:

$ xmodmap -pke | grep dead_greek

For example, on my system this command outputs:

keycode 191 = dead_greek dead_greek dead_greek dead_greek

This means that key 191 is my <dead_greek> key. On my keyboard this corresponds to the F13 key. If you are not sure which key the keycode corresponds to, you can run the following command and type all keys until you find the one with the right keycode:

$ xev | grep keycode

If the xmodmap command above returns nothing, it means that you do not have a <dead_greek> key assigned. To assign one, first find the keycode of the key you want to assign using the xev command above, then type the following command (replacing 191 with whatever keycode you want):

$ xmodmap -e "keycode 191 = dead_greek dead_greek dead_greek dead_greek"

The four repetitions of dead_greek are for various combinations of the <dead_greek> key with the Shift and AltGr keys. You will probably want to add this command to your ~/.xsessionrc script so that it runs automatically every time you login.

2. Type Greek characters, and more! :)

Now you can try typing your <dead_greek> key followed by the letter e or p, and this should print ε or π.

But wait, there's more! If you type <Multi_key> v /, you get √. On my system, the <Multi_key> is the Caps Lock key.

And there are actually a lot more key sequences predefined. If you want to find what other characters are available, look at the file /usr/share/X11/locale/en_US.UTF-8/Compose (change the en_US.UTF-8 directory to match your locale if necessary) and search for <dead_greek>.

3. How do I define more key sequences?

If you want to add more key sequences for greek characters (or for any unicode character, in fact), you can create an .XCompose file in your home directory, for example:

include "%L"
<dead_greek> <c>            : "∂"   U2202    # PARTIAL DIFFERENTIAL
<dead_greek> <C>            : "∇"   U2207    # NABLA

The include makes sure you keep the key sequences defined for your locale. In this example, we add two key sequences for ∂ and ∇. Okay, these characters aren't actually Greek, but they look like they do, so who cares?

4. What if it fails?

If some apps ignore your personalized key sequences, you may need to add the following environment variables to your .xsessionrc script:

export GTK_IM_MODULE="xim"
export QT_IM_MODULE="xim"

Enjoy!