教程/ Compose 键
介绍
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:
These descriptions were tested on several Kubuntu Hardy Heron 8.04.1 systems. 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.
如下的教程会设定一个<compose>键,,同时映射到<right logo>键(多数键盘上这个logo 是Windows logo)。
Console Configuration
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.
KDE 3.x 设置
现在我们继续,设置我们的窗口环境(Plasma)。这里用的是Kcontrol或叫 Kubuntu 配置工具,打开的是一样的设置对话框。
- 启动 系统设置(System Settings)或叫KDE 控制中心(Control Centre)
- (系统设置)或 (控制中心) ->
- 选择你的键盘布局
- 修改 ,选择/启用compose key
KDE SC 4.0-4.4 configuration
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
- Select the configuration
- Under the Layout tab, select
- Modify Advanced options to select/enable the compose key
Current KDE Configuration
These instructions apply to KDE 4.5 and above.
- Start System Settings
- Keyboard tab at left (should be initially selected)
- tab at top right
- Expand .
- Choose the key you prefer
Plasma Workspace
- Start System Settings
- Select then
- Click the tab
- Click the box next to 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
Configuration for GTK Applications (Gnome, Firefox, etc.)
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
对于单个程序,你可以这样做:只要设定程序的环境变量GTK_IM_MODULE值为xim:
$ GTK_IM_MODULE=xim firefox
对于单个 shell 会话永久的设置可以这样:
$ export GTK_IM_MODULE=xim
这条变量设置可以放到~/.bash_profile来设定单个用户下的G系程序都是如此,或是放到/etc/environment来设定全部用户都是如此。这种做法并怎么好,更好的方法在下面。
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
既然你当前用 XIM,你可以进一步调整 XCompose 输入映射便于输入更多字符,或是调整键位安排方便输入等等。
照下面这样做:
- 创建一个~/.XCompose文件,复制下列字段进去:
# ~/.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
Links and Further Information
- http://cyberborean.wordpress.com/2008/01/06/compose-key-magic/
- http://ubuntuforums.org/showthread.php?t=209115
- http://www.seedwiki.com/wiki/takomapark/compose2
- http://wiki.linuxquestions.org/wiki/Accented_Characters
- http://people.uleth.ca/~daniel.odonnell/Blog/custom-keyboard-in-linuxx11
- http://hdante.blogspot.com/2007/05/kiel-oni-skribas-typing-esperanto.html