Tutorials/ComposeKey: Difference between revisions

From KDE Wiki Sandbox
m (Fix grammar: don't -> does not)
 
(28 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{Template:I18n/Language Navigation Bar|ComposeKey}}
<languages />
<translate>


= Using/Configuring the Compose Key =
== Introduction == <!--T:2-->
== Introduction ==
 
<!--T:3-->
The ''compose key'' is used to enter characters on the keyboard that are usually not available on the key caps. Such letters could be an "umlaut", a "macron" or accents on letters:
The ''compose key'' is used to enter characters on the keyboard that are usually not available on the key caps. Such letters could be an "umlaut", a "macron" or accents on letters:
* http://en.wikipedia.org/wiki/Umlaut_(diacritic)
* http://en.wikipedia.org/wiki/Umlaut_(diacritic)
* http://en.wikipedia.org/wiki/Macron
* http://en.wikipedia.org/wiki/Macron_(diacritic)


The descriptions have been tested on several ''Kubuntu Hardy Heron 8.04.1'' systems. Further information may be found in the ''Links and Further Information'' section below.
<!--T:4-->
Further information may be found in the ''[[#Links and Further Information|Links and Further Information]]'' section below.


The modifications will work with (almost) all applications, including the desktop environment, browsers, OpenOffice.org, as well as many console/text only applications.
<!--T:5-->
The modifications will work with (almost) all applications, including the desktop environment, browsers, LibreOffice, as well as many console/text only applications.


The following instructions will configure a ''<compose> key,'' which will be mapped to the ''<right logo>'' key (on most keyboards this logo is the ''Windows'' logo).
<!--T:6-->
The following instructions will configure a ''compose'' key, which will be mapped to the ''right logo key'' (on most keyboards this logo is the ''Windows'' logo).


== Console Configuration ==
== Plasma Workspace == <!--T:54-->
 
<!--T:55-->
[[Image:system-settings-compose.png]]
 
<!--T:56-->
* Start [[Special:myLanguage/System Settings|System Settings]]
 
<!--T:57-->
* Select <menuchoice>Input Devices</menuchoice> then <menuchoice>Keyboard</menuchoice>
 
<!--T:58-->
* Click the <menuchoice>Advanced</menuchoice> tab
 
<!--T:59-->
* Click the box next to <menuchoice>Configure Keyboard Options</menuchoice> to enable changing keyboard options
 
<!--T:60-->
* Click the {{Icon|breeze-go-next}} icon next to '''Position of Compose key'''
 
<!--T:61-->
* Click the box next to the desired key to enable it
 
== Console Configuration == <!--T:7-->
 
<!--T:62-->
̣{{Note|This instruction are old and only works in Debian based system. If you know a better way, feel free to edit this wiki page.}}
 
<!--T:8-->
To do this properly I'm trying to go the "holistic way" starting with the console:
To do this properly I'm trying to go the "holistic way" starting with the console:


<!--T:9-->
* Reconfigure the console for the used keyboard, and the character encoding. Do this in a text terminal or the console.
* Reconfigure the console for the used keyboard, and the character encoding. Do this in a text terminal or the console.
{{Input|1= $ sudo dpkg-reconfigure console-setup}}


$ sudo dpkg-reconfigure console-setup
<!--T:10-->
 
* Follow these steps in the configuration:
* Follow these steps in the configuration:
** Choose your keyboard (here a default 104 US keyboard)
** Choose your keyboard (here a default 104 US keyboard)
** If you want the !AltGr key replacement, choose one
** If you want the !AltGr key replacement, choose one
** Choose which key you would like your ''compose key'' to be mapped to. I use the '''right logo key.''' <BR> I'd much rather like to use the '''left logo key,''' but that's not available in the console setting. But in the graphical window environment (KDE Plasma) that is possible.
** Choose which key you would like your ''compose key'' to be mapped to. I use the ''right logo key.''<p>I'd much rather like to use the ''left logo key,'' but that's not available in the console setting. But in the graphical window environment (KDE Plasma) that is possible.</p>
** Choose the console's encoding, set it to '''UTF-8'''
** Choose the console's encoding, set it to ''UTF-8''
** Choose what character set should be available on the console. I use '''Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic''' <BR> I guess that selection should give me the wanted characters.
** Choose what character set should be available on the console. I use ''Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic''<p>I guess that selection should give me the wanted characters.</p>
** Choose what type of console output you'd like (do whatever you like, to be safe you can go with the given current defaults)
** Choose what type of console output you'd like (do whatever you like, to be safe you can go with the given current defaults)
** A new ''initial RAM disk'' for the next boot will be created now.
** A new ''initial RAM disk'' for the next boot will be created now.


== KDE 3.x Configuration ==
== Configuration for GTK Applications (Gnome, Firefox, etc.) == <!--T:18-->
Now we can go on and configure our windowing environment (Plasma). This description uses either ''Kcontrol'' or the Kubuntu configuration tool, exposes the same option dialogue.


* Start the ''System Settings'' or the ''KDE Control Centre''
<!--T:63-->
* ''Regional & Language'' (for System Settings) or ''Regional & Accessibility'' (for Control Centre) <BR> -> ''Keyboard Layout''
{{Note|This instruction are probably obsolete. If GTK applications don't work ''out-of-the-box'', please go to the [[Special:myLanguage/Tutorials/ComposeKey#Troubleshooting|Troubleshooting section]].}}
* Choose your keyboard layout
* Modify the ''Xkb Options'' to select/enable the ''compose key''


[[Image:ControlKeyKDE3.png]]
<!--T:19-->
GTK (such as also Firefox) and Gnome applications use (on an Ubuntu system) usually ''SCIM'' as the input method, not ''XIM'' (X Input Method) that relies on the configurations from (X)Compose. Therefore, you will often find that the "a" and "o" macron characters can yield the female/male ordinals "ª" and "º". To still make it work, GTK applications need to be "told" to use XIM instead.


== KDE SC 4.x configuration ==
=== "One Off" Configuration === <!--T:20-->
Now we can go on and configure our windowing environment (Plasma). This description uses the ''System Settings'' as they're available in the K-Menu of the Kubuntu install:
 
* Start the ''System Settings''
* ''Regional & Language''
* Select the ''Keyboard Layout'' configuration
* Under the ''Layout'' tab, select ''Enable keyboard layouts''
* Modify ''Advanced'' options to select/enable the ''compose key''


[[Image:ControlKeyKDE4.png]]
<!--T:21-->
For a single application you can do it by just setting the environment variable ''GTK_IM_MODULE'' for the application to be launched to '''xim''':


== Configuration for Gtk Applications (Gnome, FireFox, etc.) ==
<!--T:22-->
Gtk (such as also FireFox) and Gnome applications use (on an Ubuntu system) usually ''SCIM'' as the input method, not ''XIM'' (X Input Method) that relies on the configurations from (X)Compose. Therefore, you will often find that the "a" and "o" macron characters can yield the female/male ordinals "ª" and "º". To still make it work, Gtk applications need to be "told" to use XIM instead.
{{Input|1= $ GTK_IM_MODULE=xim firefox}}


=== "One Off" Configuration ===
<!--T:23-->
For a single application you can do it by just setting the environment variable '''GTK_IM_MODULE''' for the application to be launched to '''xim''':
More permanently that can be done for a single shell session like this:
 
$ GTK_IM_MODULE=xim firefox


More permanently that can be done for a single shell session like this:
<!--T:24-->
{{Input|1= $ export GTK_IM_MODULE=xim}}


$ export GTK_IM_MODULE=xim
<!--T:25-->
This can, of course, also be persisted for a single user in your ''~/.bash_profile'', or for all users in ''/etc/environment''. This is, however, the less elegant way, the more elegant way follows below.


This can, of course, also be persisted for a single user in your '''~/.bash_profile''', or for all users in '''/etc/environment'''. This is, however, the less elegant way, the more elegant way follows below.
=== Persistent Configuration === <!--T:26-->


=== Persistent Configuration ===
<!--T:27-->
* Copy the setup file '''/etc/X11/xinit/xinput.d/default''' to '''/etc/X11/xinit/xinput.d/xim'''
* Copy the setup file ''/etc/X11/xinit/xinput.d/default'' to ''/etc/X11/xinit/xinput.d/xim''


$ sudo cp /etc/X11/xinit/xinput.d/default /etc/X11/xinit/xinput.d/xim
<!--T:28-->
{{Input|1= $ sudo cp /etc/X11/xinit/xinput.d/default /etc/X11/xinit/xinput.d/xim}}


* Edit the file '''/etc/X11/xinit/xinput.d/xim''' and set the input method for '''GNOME''' and '''KDE''' to '''xim'''
<!--T:29-->
* Edit the file ''/etc/X11/xinit/xinput.d/xim'' and set the input method for ''GNOME'' and ''KDE'' to ''xim''


<!--T:30-->
{{Input|1=
  ...
  ...
  GTK_IM_MODULE=xim
  GTK_IM_MODULE=xim
  QT_IM_MODULE=xim
  QT_IM_MODULE=xim
  ...
  ...
}}
<!--T:31-->
* Create a link for the locale ''all_ALL'' (or the desired locale only):


* Create a link for the locale '''all_ALL''' (or the desired locale only):
<!--T:32-->
{{Input|1= $ sudo ln -sf /etc/X11/xinit/xinput.d/xim /etc/X11/xinit/xinput.d/all_ALL}}


$ sudo ln -sf /etc/X11/xinit/xinput.d/xim /etc/X11/xinit/xinput.d/all_ALL
<!--T:53-->
If you are using a Debian-derived distribution use following instead
{{Input|1= $ sudo update-alternatives --verbose --install /etc/X11/xinit/xinput.d/all_ALL xinput-all_ALL /etc/X11/xinit/xinput.d/xim 20}}


<!--T:33-->
* After a restart of the X server everything should work.
* After a restart of the X server everything should work.


=== Optional Tweaking of XCompose Map ===
=== Optional Tweaking of XCompose Map === <!--T:34-->
 
<!--T:35-->
Now that you're using XIM, you can further tweak the XCompose input map for further characters, or for characters in more convenient locations, etc.
Now that you're using XIM, you can further tweak the XCompose input map for further characters, or for characters in more convenient locations, etc.


<!--T:36-->
To do that follow these steps:
To do that follow these steps:
* Create a '''~/.XCompose''' file, and put the following lines into it:
* Create a ''~/.XCompose'' file, and put the following lines into it:


<!--T:37-->
{{Input|1=
  # ~/.XCompose
  # ~/.XCompose
  # This file defines custom Compose sequences for Unicode characters
  # This file defines custom Compose sequences for Unicode characters<br />
 
# Import default rules from the system Compose file:
# Import default rules from the system Compose file:
  include "/usr/share/X11/locale/en_US.UTF-8/Compose"<br />
  include "/usr/share/X11/locale/en_US.UTF-8/Compose"
# To put some stuff onto compose key strokes:
 
# To put some stuff onto compose key strokes:
  <Multi_key> <minus> <greater> : "→" U2192 # Compose - >
  <Multi_key> <minus> <greater> : "→" U2192 # Compose - >
  <Multi_key> <colon> <parenright> : "☺" U263A  # Compose : )
  <Multi_key> <colon> <parenright> : "☺" U263A  # Compose : )
  <Multi_key> <h> <n> <k> : "hugs and kisses" # Compose h n k
  <Multi_key> <h> <n> <k> : "hugs and kisses" # Compose h n k
  <Multi_key> <less> < p> : "< p></p>" # Compose < p
  <Multi_key> <less> < p> : "< p></p>" # Compose < p
}}


<!--T:40-->
* Just log out and in again (no restart necessary), and you can use your new "multi key short strokes" using the compose key to your desire. As you see this even works for creating longer character sequences.
* Just log out and in again (no restart necessary), and you can use your new "multi key short strokes" using the compose key to your desire. As you see this even works for creating longer character sequences.


== Typing Macrons, Umlauts, Accents, ... ==
== Typing Macrons, Umlauts, Accents, ... == <!--T:41-->
The ''<compose>'' will be now whatever you have configured it to be, e. g. ''<right logo>.''
 
<!--T:42-->
The <keycap>compose</keycap> key will be now whatever you have configured it to be, e. g. <keycap>right logo</keycap>.


<!--T:43-->
* Macrons
* Macrons
** ''<compose>'' + ''<shift>'' + ''<hyphen>'' then ''<vowel>'' <BR> (or ''<compose>'' + ''<underscore>'' then ''<vowel>'') <BR> --> āēīōū ĀĒĪŌŪ
{{Input|1=<keycap>compose + shift + hyphen</keycap> then ''<vowel >''}}or {{Input|1=<keycap>compose + underscore</keycap> then ''<vowel >''}}
 
<!--T:44-->
&rarr; {{Output|1=āēīōū ĀĒĪŌŪ}}
 
 
<!--T:45-->
* Umlauts
* Umlauts
** ''<compose>'' + ''<shift>'' + ''<single quote>'' then ''<vowel>'' <BR> (or ''<compose>'' + ''<double quotes>'' then '<vowel>'') <BR> --> äëïöü ÄËÏÖÜ
{{Input|1=<keycap>compose + shift + <single quote></keycap> then ''<vowel >''}}or {{Input|1=<keycap>compose + <double quotes></keycap> then ''<vowel >''}}
 
<!--T:46-->
&rarr; {{Output|1=äëïöü ÄËÏÖÜ}}
 
 
<!--T:47-->
* The German ''Ess-Zet'' ligature
* The German ''Ess-Zet'' ligature
** ''<compose>'' then "s" and "s" (twice the "s") <BR> --> ß
{{Input|1=<keycap>compose</keycap> then <keycap>s</keycap> and <keycap>s</keycap> (twice the "s")}}
 
<!--T:48-->
&rarr; {{Output|1=ß }}
 
 
<!--T:49-->
* More bindings can be found in ''/usr/share/X11/locale/en_US.UTF-8/Compose''
 
</translate><span id="Links and Further Information"></span><translate>
 
== Troubleshooting == <!--T:64-->
 
=== Compose key does not work in GTK applications === <!--T:65-->
 
<!--T:66-->
In {{Path|.xinputrc}}, delete the line with the following content: <code>run_im ibus</code>. Then reboot your computer, or restart the X server.


* More bindings can be found in '''/usr/share/X11/locale/en_US.UTF-8/Compose'''
== More Information == <!--T:50-->


== Links and Further Information ==
<!--T:51-->
* http://cyberborean.wordpress.com/2008/01/06/compose-key-magic/
* http://cyberborean.wordpress.com/2008/01/06/compose-key-magic/
* http://ubuntuforums.org/showthread.php?t=209115
* http://ubuntuforums.org/showthread.php?t=209115
Line 122: Line 196:
* http://hdante.blogspot.com/2007/05/kiel-oni-skribas-typing-esperanto.html
* http://hdante.blogspot.com/2007/05/kiel-oni-skribas-typing-esperanto.html


<!--T:52-->
[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Advanced Users]]
[[Category:Advanced Users]]
</translate>

Latest revision as of 11:56, 19 July 2022

Introduction

The compose key is used to enter characters on the keyboard that are usually not available on the key caps. Such letters could be an "umlaut", a "macron" or accents on letters:

Further information may be found in the Links and Further Information section below.

The modifications will work with (almost) all applications, including the desktop environment, browsers, LibreOffice, as well as many console/text only applications.

The following instructions will configure a compose key, which will be mapped to the right logo key (on most keyboards this logo is the Windows logo).

Plasma Workspace

  • Select Input Devices then Keyboard
  • Click the Advanced tab
  • Click the box next to Configure Keyboard Options to enable changing keyboard options
  • Click the icon next to Position of Compose key
  • Click the box next to the desired key to enable it

Console Configuration

̣

Note
This instruction are old and only works in Debian based system. If you know a better way, feel free to edit this wiki page.


To do this properly I'm trying to go the "holistic way" starting with the console:

  • Reconfigure the console for the used keyboard, and the character encoding. Do this in a text terminal or the console.
$ sudo dpkg-reconfigure console-setup
  • Follow these steps in the configuration:
    • Choose your keyboard (here a default 104 US keyboard)
    • If you want the !AltGr key replacement, choose one
    • Choose which key you would like your compose key to be mapped to. I use the right logo key.

      I'd much rather like to use the left logo key, but that's not available in the console setting. But in the graphical window environment (KDE Plasma) that is possible.

    • Choose the console's encoding, set it to UTF-8
    • Choose what character set should be available on the console. I use Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic

      I guess that selection should give me the wanted characters.

    • Choose what type of console output you'd like (do whatever you like, to be safe you can go with the given current defaults)
    • A new initial RAM disk for the next boot will be created now.

Configuration for GTK Applications (Gnome, Firefox, etc.)

Note
This instruction are probably obsolete. If GTK applications don't work out-of-the-box, please go to the Troubleshooting section.


GTK (such as also Firefox) and Gnome applications use (on an Ubuntu system) usually SCIM as the input method, not XIM (X Input Method) that relies on the configurations from (X)Compose. Therefore, you will often find that the "a" and "o" macron characters can yield the female/male ordinals "ª" and "º". To still make it work, GTK applications need to be "told" to use XIM instead.

"One Off" Configuration

For a single application you can do it by just setting the environment variable GTK_IM_MODULE for the application to be launched to xim:

$ GTK_IM_MODULE=xim firefox

More permanently that can be done for a single shell session like this:

$ export GTK_IM_MODULE=xim

This can, of course, also be persisted for a single user in your ~/.bash_profile, or for all users in /etc/environment. This is, however, the less elegant way, the more elegant way follows below.

Persistent Configuration

  • Copy the setup file /etc/X11/xinit/xinput.d/default to /etc/X11/xinit/xinput.d/xim
$ sudo cp /etc/X11/xinit/xinput.d/default /etc/X11/xinit/xinput.d/xim
  • Edit the file /etc/X11/xinit/xinput.d/xim and set the input method for GNOME and KDE to xim
...
 GTK_IM_MODULE=xim
 QT_IM_MODULE=xim
 ...
  • Create a link for the locale all_ALL (or the desired locale only):
$ sudo ln -sf /etc/X11/xinit/xinput.d/xim /etc/X11/xinit/xinput.d/all_ALL

If you are using a Debian-derived distribution use following instead

$ sudo update-alternatives --verbose --install /etc/X11/xinit/xinput.d/all_ALL xinput-all_ALL /etc/X11/xinit/xinput.d/xim 20
  • After a restart of the X server everything should work.

Optional Tweaking of XCompose Map

Now that you're using XIM, you can further tweak the XCompose input map for further characters, or for characters in more convenient locations, etc.

To do that follow these steps:

  • Create a ~/.XCompose file, and put the following lines into it:
# ~/.XCompose
 # This file defines custom Compose sequences for Unicode characters
# Import default rules from the system Compose file: include "/usr/share/X11/locale/en_US.UTF-8/Compose"
# To put some stuff onto compose key strokes: <Multi_key> <minus> <greater> : "→" U2192 # Compose - > <Multi_key> <colon> <parenright> : "☺" U263A # Compose : ) <Multi_key> <h> <n> <k> : "hugs and kisses" # Compose h n k <Multi_key> <less> < p> : "< p>

" # Compose < p
  • Just log out and in again (no restart necessary), and you can use your new "multi key short strokes" using the compose key to your desire. As you see this even works for creating longer character sequences.

Typing Macrons, Umlauts, Accents, ...

The compose key will be now whatever you have configured it to be, e. g. right logo.

  • Macrons
compose + shift + hyphen then <vowel >

or

compose + underscore then <vowel >

āēīōū ĀĒĪŌŪ


  • Umlauts
compose + shift + <single quote> then <vowel >

or

compose + <double quotes> then <vowel >

äëïöü ÄËÏÖÜ


  • The German Ess-Zet ligature
compose then s and s (twice the "s")

ß


  • More bindings can be found in /usr/share/X11/locale/en_US.UTF-8/Compose

Troubleshooting

Compose key does not work in GTK applications

In .xinputrc, delete the line with the following content: run_im ibus. Then reboot your computer, or restart the X server.

More Information