Rime

From ArchWiki

Rime is an input method engine for entering Chinese characters, supporting a wide range of input methods.

The Rime engine itself does not provide a frontend for receiving user input. It must be used with an input method framework such as Fcitx5 or IBus.

Note: Fcitx5 and Fcitx are two different packages. Fcitx is in maintenance mode and people are advised to use Fcitx5 instead. Since 2021, the official page of fcitx-im points to Fcitx5. As the official packages have not renamed to reflect this change, pay a special attention to the sections below.

Installation

Install the librime package containing the Rime engine, and the integration corresponding with your IMF:

Configuration

In order for Rime to work, input schemas are needed. Schemas are text files that can be created and customized by users. Alternatively, there are several input schemas available in package repository:

By default, some schemas are installed with librime-data meta package as it is a dependency of librime.

Some schema packages provide more than one schemas. For example, rime-luna-pinyin provides 5 schemas including luna_pinyin and luna_pinyin_fluency. You can check content of each package from Rime GitHub organization.

You can switch input schema at any time by pressing F4 to trigger the program menu. See #Selecting input method.

Configuration directory

To customize Rime, you should first create the Rime configuration directory. Assuming you are using ibus-rime:

$ mkdir ~/.config/ibus/rime

Or if you are using fcitx-rime:

$ mkdir ~/.config/fcitx/rime/

Or if you are using Fcitx5:

$ mkdir ~/.local/share/fcitx5/rime/

In this directory, create a file named default.custom.yaml, where you specify your input schema of choice. For example, if you want to be able to type pinyin with tones, you can use the Terra Pinyin input method by adding it to the list of enabled schemas:

default.custom.yaml
patch:
  schema_list:
    - schema: terra_pinyin

Note that the indentation level is important. This file overrides the default configuration, so if you only add Terra Pinyin, it will be the only schema enabled.

Apply configuration

To make the customizations effective, you need to redeploy. If you have working IBus or Fcitx GUI, you may find a ⟲ (Deploy) button and click it. Alternatively, use the following command, assuming you are using ibus-rime:

$ rm ~/.config/ibus/rime/default.yaml && ibus-daemon -drx

Or if you are using fcitx-rime:

$ rm ~/.config/fcitx/rime/default.yaml && fcitx-remote -r

Or if you are using fcitx5-rime:

$ rm ~/.local/share/fcitx5/rime/default.yaml && fcitx5-remote -r

Tones

Specifying tones is optional but they are very useful for filtering the list:

1st tone: -
2nd tone: /
3rd tone: <
4th tone: \

For example, if one wants to type hǎo to display only Chinese characters that are pronounced this way, one must type hao< and it will be automatically converted to "hǎo".

Input candidates

By default, RIME only displays five candidates for input whilst typing. You can change this by setting the "menu/page_size" value manually.

default.custom.yaml
patch:
     "menu/page_size": 9

Usage

Selecting input method

By default, while running Rime, you can access some basic options with F4 or Ctrl+`. The displayed options look like this:

1. Method name
2. 中文 -› 西文
3. 全角 -› 半角
4. 漢字 -› 汉字
etc.

The first one indicates the name of the method you have selected (Ex: 地球拼音 for Terra Pinyin). If you have enabled multiple input methods, you can switch between them.

The other options depend on the current input method:

The second one lets you switch between Chinese and western languages.

The third one lets you select if you want to type the punctuation in full width (全角) or in half width (半角).

The last one allows you to switch between traditional Chinese (漢字) and simplified Chinese (汉字).

Configure input method

Rather than open the menu each time it's possible to override the default options of a particular input method. This requires creating a "custom" config file that modifies the "schema" of the input method.

Example

For example, to change the Terra Pinyin default from traditional Chinese to simplified Chinese:

The schema file installed for rime-terra-pinyin is /usr/share/rime-data/build/terra_pinyin.schema.yaml. Refer to the switches section in the schema file:

switches:
  - name: ascii_mode
    reset: 0
    states: ["中文", "西文"]
  - name: full_shape
    states: ["半角", "全角"]
  - name: simplification
    states: ["漢字", ]
  - name: ascii_punct
    states: ["。,", ".,"]

These are the choices shown when Terra Pinyin is active and the options menu is opened with F4 or Ctrl+`. For a different input method, the schema file will be different.

Create a custom config file for Terra Pinyin in your Rime #Configuration directory:

terra_pinyin.custom.yaml
patch:
  switches:
    - name: simplification
      reset: 1

name matches the entry in the schema file switches list. reset: 1 configure rime to always reset this item to the second choice (index 1, or "汉字").

#Apply configuration to load the customized config.

Rime provides multiple YAML syntax methods for this type of customization; see #Advanced for more examples.

Chinese punctuation

Chinese punctuation is typed like so:

[ -> 「 【 〔 [
] -> 」 】 〕 ]
{ -> 『 〖 {
} -> 』 〗 }
< -> 《 〈 « ‹
> -> 》 〉 » ›
@ -> @ @ ☯
/ -> / / ÷
* -> * * ・ × ※
% -> % % ° ℃
$ -> ¥ $ € £ ¥
| -> ・ | | § ¦
_ -> ——
\ -> 、 \ \
^ -> ……
~ -> 〜 ~ ~ 〰

Advanced

More advanced examples are provided on the project website (in Chinese).

Troubleshooting

ibus-setup set orientation invaild in GNOME environment

See issue #52. Create ~/.config/ibus/rime/build/ibus_rime.yaml with follows:

style:
  horizontal: true

Tips and tricks

Greek letters

Greek characters can be typed by adding the following to luna_pinyin.custom.yaml or a custom input scheme file:

luna_pinyin.custom.yaml
recognizer:
  patterns:
    # Use / as the identifier here
    # You can freely replace your favorite identifiers (such as: `~, .\; etc., characters that need not be displayed directly on the screen)
    # Replace the / before the Greek letter at the same time
    punct: "^/([0-9]0?|[A-Za-z]+)$"
punctuator:
  symbols:
    # Here, the letter name is used as the code of the Greek letter, and you can replace it with your favorite code as needed.
    # For example, if you want to use a as the alpha code
    # just replace the alpha below with a
    "/alpha": ["Α", "α"]
    "/beta": ["Β", "β"]
    "/gamma": ["Γ", "γ"]
    "/delta": ["Δ", "δ"]
    "/epsilon": ["Ε", "ε"]
    "/zeta": ["Ζ", "ζ"]
    "/eta": ["Η", "η"]
    "/theta": ["Θ", "θ"]
    "/iota": ["Ι", "ι"]
    "/kappa": ["Κ", "κ"]
    "/lambda": ["Λ", "λ"]
    "/mu": ["Μ", "μ"]
    "/nu": ["Ν", "ν"]
    "/xi": ["Ξ", "ξ"]
    "/omicron": ["Ο", "ο"]
    "/pi": ["Π", "π"]
    "/rho": ["Ρ","ρ"]
    "/sigma": ["Σ", "σ", "ς"]
    "/tau": ["Τ", "τ"]
    "/upsilon": ["Υ", "υ"]
    "/phi": ["Φ", "φ"]
    "/chi": ["Χ", "χ"]
    "/psi": ["Ψ", "ψ"]
    "/omega": ["Ω", "ω"]

For example, with this scheme, the character α is produced by typing /alpha.

See also