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!
I changed the switch key-combination to "Alt + Space", and it works now. Does anyone know what could be catching the "Alt + Alt" combo? – Matthew – 2009-08-24T20:09:16.030
Not sure. Ctrl-Ctrl doesn't work for me either. – innaM – 2009-08-26T09:13:50.807