What’s the problem?
The problem is that Greek keyboards are based on the United States
layout: for example, they have the ‘commercial at’
symbol ‘@’
on shift-2, which, to us Britishers, is where double quote should
be.
So the natural way of configuring your keyboard to work in either
Roman or Greek characters leaves you with US-layout punctuation
when in Greek mode, which is not ideal if your keyboard has
a UK layout.
The information below applies to the Debian ‘Woody’
distribution, and is independent of desktop programs such as Gnome
or KDE. Other distributions may be sufficiently similar
for the information to be helpful. There may well be an easier way
to achieve all this: if you know of one, please let me know.
One alternative approach involves using UTF-8 encodings; this
can, however, create more problems than it solves.
Step 1: make sure you have some suitable fonts
You will need suitable fonts for the ordinary Roman character set
(ISO-8859-1), which covers most of the western European languages,
and for the Greek character set (ISO-8859-7). You may already
have such fonts installed:
xlsfonts | grep fixed.*8859-1
and
xlsfonts | grep fixed.*8859-7
should tell you. Try commands like
xterm -fn -etl-fixed-medium-r-normal--16-160-72-72-c-80-iso8859-7 &
until you find a font you like the look of. If you
don’t have any ISO-8859-7 fonts installed, you will need to
find a suitable package. Try
apt-cache search 8859-7
and see what’s available. I installed the package xfonts-intl-european:
apt-get install xfonts-intl-european
which includes the font mentioned in the example command above. (You
need to be root to install new packages.)
Step 2: create new xterm
commands
You need to be root for the following steps.
You can now create a couple of new commands to simplify running
xterm
s using the new fonts. I created two new files in
/usr/local/bin
: xterm1
to run a terminal
with the ISO-8859-1 character set, and xterm7
, to
run a terminal
with the ISO-8859-7 character set:
/usr/local/bin/xterm1:
export LANG=en_GB
xterm -T "xterm en_GB (ISO 8859-1)" -fn -misc-fixed-medium-r-normal--20-140-100-100-c-100-iso8859-1
/usr/local/bin/xterm7:
export LANG=el_GR
xterm -T "xterm el_GR (ISO 8859-7)" -fn -etl-fixed-medium-r-normal--16-160-72-72-c-80-iso8859-7
The export LANG=
lines set the locale for the xterm
.
If you did not include these locales when you first configured your system
(or if you aren’t sure), then type
dpkg-reconfigure locales
and make sure both en_GB
and el_GR
are selected.
Do not deselect any locales that show as already selected.
Why does the locale need to be set? Although the basic mapping between
keys on the keyboard and the characters they produce is under control
of xkb
(which we will configure below), the action
of the ‘Compose’ key (the right-hand Windows key on my
keyboard) is locale-dependent. We want different xterm
windows to have different ‘Compose’ key actions, depending
on whether they are in Roman or in Greek mode, and
this means they have to run in different locales.
Step 3: create a new keyboard mapping
Create a new Greek keyboard map /etc/X11/xkb/symbols/el_GB
.
This is very similar to the existing Greek map in
/etc/X11/xkb/symbols/el
, but is modified to reflect the
UK keyboard layout. The contents of the new file should be as
follows (I have included the original versions of changed lines as
comments):
// $XFree86$
//
default partial alphanumeric_keys alternate_group
xkb_symbols "basic" {
include "el_GB(bare)"
// key <TLDE> { [], [ quoteleft, asciitilde ] };
key <TLDE> { [], [ quoteleft, notsign ] };
key <AE01> { [], [ 1, exclam ] };
// key <AE02> { [], [ 2, at ] };
key <AE02> { [], [ 2, quotedbl ] };
// key <AE03> { [], [ 3, numbersign ] };
key <AE03> { [], [ 3, sterling ] };
key <AE04> { [], [ 4, dollar ] };
key <AE05> { [], [ 5, percent ] };
key <AE06> { [], [ 6, asciicircum ] };
key <AE07> { [], [ 7, ampersand ] };
key <AE08> { [], [ 8, asterisk ] };
key <AE09> { [], [ 9, parenleft ] };
key <AE10> { [], [ 0, parenright ] };
key <AE11> { [], [ minus, underscore ] };
key <AE12> { [], [ equal, plus ] };
key <AD11> { [], [ bracketleft, braceleft ] };
key <AD12> { [], [ bracketright, braceright ] };
// key <AC11> { [], [ quoteright, quotedbl ] };
key <AC11> { [], [ quoteright, at ] };
key <AB08> { [], [ comma, less ] };
key <AB09> { [], [ period, greater ] };
key <AB10> { [], [ slash, question ] };
// key <BKSL> { [], [ backslash, bar ] };
key <BKSL> { [], [ numbersign, asciitilde ] };
};
hidden partial alphanumeric_keys alternate_group
xkb_symbols "bare" {
name[Group2] = "ISO8859-7";
key <AD01> { [], [ semicolon, colon ] };
key <AD02> { [], [ Greek_finalsmallsigma, Greek_SIGMA ] };
key <AD03> { [], [ Greek_epsilon, Greek_EPSILON ] };
key <AD04> { [], [ Greek_rho, Greek_RHO ] };
key <AD05> { [], [ Greek_tau, Greek_TAU ] };
key <AD06> { [], [ Greek_upsilon, Greek_UPSILON ] };
key <AD07> { [], [ Greek_theta, Greek_THETA ] };
key <AD08> { [], [ Greek_iota, Greek_IOTA ] };
key <AD09> { [], [ Greek_omicron, Greek_OMICRON ] };
key <AD10> { [], [ Greek_pi, Greek_PI ] };
key <AC01> { [], [ Greek_alpha, Greek_ALPHA ] };
key <AC02> { [], [ Greek_sigma, Greek_SIGMA ] };
key <AC03> { [], [ Greek_delta, Greek_DELTA ] };
key <AC04> { [], [ Greek_phi, Greek_PHI ] };
key <AC05> { [], [ Greek_gamma, Greek_GAMMA ] };
key <AC06> { [], [ Greek_eta, Greek_ETA ] };
key <AC07> { [], [ Greek_xi, Greek_XI ] };
key <AC08> { [], [ Greek_kappa, Greek_KAPPA ] };
key <AC09> { [], [ Greek_lamda, Greek_LAMDA ] };
key <AC10> { [], [ dead_acute, dead_diaeresis ] };
key <AB01> { [], [ Greek_zeta, Greek_ZETA ] };
key <AB02> { [], [ Greek_chi, Greek_CHI ] };
key <AB03> { [], [ Greek_psi, Greek_PSI ] };
key <AB04> { [], [ Greek_omega, Greek_OMEGA ] };
key <AB05> { [], [ Greek_beta, Greek_BETA ] };
key <AB06> { [], [ Greek_nu, Greek_NU ] };
key <AB07> { [], [ Greek_mu, Greek_MU ] };
// key <LSGT> { [], [ guillemotleft, guillemotright ] };
key <LSGT> { [], [ backslash, bar ] };
};
partial alphanumeric_keys alternate_group
xkb_symbols "Sundeadkeys" {
include "el_GB(basic)"
};
partial alphanumeric_keys alternate_group
xkb_symbols "sundeadkeys" {
include "el_GB(Sundeadkeys)"
};
partial alphanumeric_keys alternate_group
xkb_symbols "nodeadkeys" {
include "el_GB(basic)"
key <AC10> { [], [ semicolon, colon ] };
};
Step 4: install the new mapping
You can test the new mapping by typing
setxkbmap -display :0 -keycodes xfree86 -symbols "en_US(pc105)+gb(basic)+el_GB(basic)+group(menu_toggle)" -v
You should find that in an xterm1
window the keyboard
works as normal and you can type e.g.
<Compose>-a-e and get ‘æ’; and that in
an xterm7
window you can switch between Roman
and Greek alphabets using the ‘Menu’ key, with
the punctuation remaining where you expect it. In Greek mode,
typing ;-a should give an accented alpha; typing :-;-i should
give an iota with both accent and dieresis, and so on. Colon
and semi-colon are on ‘Q’. The open and close
guillemot characters (between ‘Z’ and the left shift
key on Greek keyboards) can be obtained with Compose-<-< and
Compose->-> respectively.
To install the new mapping permanently, edit the keyboard section of
the file
/etc/X11/XF86Config-4
to remove the lines
Option "XkbRules" "xfree86"
Option "XkbModel" "pc105"
Option "XkbLayout" "gb"
and replace them with
Option "XkbKeycodes" "xfree86"
Option "XkbGeometry" "pc(pc105)"
Option "XkbSymbols" "en_US(pc105)+gb(basic)+el_GB(basic)+group(menu_toggle)"
You will need to restart the X server for this change to take effect.
This page most recently updated
Fri 4 Feb 16:49:52 GMT 2022