Fcitx: Difference between revisions

From ArchWiki
(→‎Firefox popup menu not work: Remove out of date issue. fcitx-gtk3 is merged to fcitx.)
 
(66 intermediate revisions by 24 users not shown)
Line 1: Line 1:
[[Category:Input methods]]
[[Category:Input methods]]
[[de:Fcitx]]
[[ja:Fcitx]]
[[ja:Fcitx]]
[[zh-hans:Fcitx]]
[[zh-hans:Fcitx]]
{{Related articles start}}
{{Related|Fcitx5}}
{{Related|IBus}}
{{Related|SCIM}}
{{Related|uim}}
{{Related articles end}}
[[Wikipedia:Fcitx|Fcitx]] is a lightweight [[input method]] framework aimed at providing environment independent language support for Linux. It supports a lot of different languages and also provides many useful non-CJK features.
[[Wikipedia:Fcitx|Fcitx]] is a lightweight [[input method]] framework aimed at providing environment independent language support for Linux. It supports a lot of different languages and also provides many useful non-CJK features.


==Installation==
{{Warning|Fcitx is now in maintenance mode. It is recommended to use [[Fcitx5]] instead.}}
 
== Installation ==
 
[[Install]] the {{Pkg|fcitx}} package.
[[Install]] the {{Pkg|fcitx}} package.
 
=== Input method engines ===
=== Input method engines ===


Line 15: Line 26:
==== Chinese ====
==== Chinese ====


* {{Pkg|fcitx-sunpinyin}}, based on {{Pkg|sunpinyin}}. It strikes a good balance between speed and accuracy.
* {{AUR|fcitx-baidupinyin}}, fcitx wrapper for Baidu Pinyin IM engine.
* {{Pkg|fcitx-chewing}} is a popular Zhuyin input engine for Traditional Chinese based on {{Pkg|libchewing}}.
* {{Pkg|fcitx-cloudpinyin}} uses internet sources to provide input candidates. The selected cloud result will be added to local dictionary. It support all fcitx pinyin input method except {{Pkg|fcitx-rime}}.
* {{Pkg|fcitx-googlepinyin}}, Googlepinyin wrapper for fcitx.
* {{Pkg|fcitx-libpinyin}}, based on {{Pkg|libpinyin}}. It has a better algorithm than {{Pkg|fcitx-sunpinyin}}.
* {{Pkg|fcitx-libpinyin}}, based on {{Pkg|libpinyin}}. It has a better algorithm than {{Pkg|fcitx-sunpinyin}}.
* {{Pkg|fcitx-rime}}, based on schemas from the [[Rime IME]] project.
* {{Pkg|fcitx-rime}}, based on schemas from the [[Rime IME]] project.
* {{Pkg|fcitx-googlepinyin}}, the Google pinyin IME for Android.
* {{AUR|fcitx-sogoupinyin}}, [https://pinyin.sogou.com/linux/ Sogou input method] supporting Jianpin, fuzzy sound, cloud input, English input, and mixed skin.
* {{AUR|fcitx-sogoupinyin}}, [http://pinyin.sogou.com/linux/ Sogou input method] supporting Jianpin, fuzzy sound, cloud input, English input, and mixed skin.
* {{Pkg|fcitx-sunpinyin}}, based on {{Pkg|sunpinyin}}. It strikes a good balance between speed and accuracy.
* {{Pkg|fcitx-cloudpinyin}} uses internet sources to provide input candidates. The selected cloud result will be added to local dictionary. It support all fcitx pinyin input method except {{Pkg|fcitx-rime}}. 
* {{Pkg|fcitx-chewing}} is a popular Zhuyin input engine for Traditional Chinese based on {{Pkg|libchewing}}.
* {{Pkg|fcitx-table-extra}}  adds [[wikipedia:Cangjie_input_method|Cangjie]], [[wikipedia:Zhengma_method|Zhengma]], [[wikipedia:Boshiamy_method|Boshiamy]] support.


==== Japanese ====
==== Japanese ====


* {{Pkg|fcitx-anthy}}, a popular Japanese input engine. However, it is not actively developed anymore.
* {{Pkg|fcitx-mozc}}, based on [[Mozc]], the Open Source Edition of Google Japanese Input.
* {{Pkg|fcitx-mozc}}, based on [[Mozc]], the Open Source Edition of Google Japanese Input.
* {{Pkg|fcitx-kkc}}, a Japanese Kana Kanji input engine, based on {{Pkg|libkkc}}.
* {{Pkg|fcitx-kkc}}, a Japanese Kana Kanji input engine, based on {{Pkg|libkkc}}.
* {{Pkg|fcitx-anthy}}, a popular Japanese input engine. However, it is not actively developed anymore.
* {{Pkg|fcitx-skk}}, a Japanese Kana Kanji input engine, based on {{Pkg|libskk}}.


==== Other languages ====
==== Other languages ====


* {{Pkg|fcitx-hangul}}, for typing Korean hangul, based on {{Pkg|libhangul}}.
* {{Pkg|fcitx-hangul}}, for typing Korean hangul, based on {{Pkg|libhangul}}.
* {{Pkg|fcitx-m17n}}, for other languages provided by [https://www.nongnu.org/m17n/ M17n].
* {{Pkg|fcitx-sayura}}, for typing Sinhalese.
* {{Pkg|fcitx-unikey}}, for typing Vietnamese characters.
* {{Pkg|fcitx-unikey}}, for typing Vietnamese characters.
* {{Pkg|fcitx-sayura}}, for typing Sinhalese.
* {{Pkg|fcitx-m17n}}, for other languages provided by [http://www.nongnu.org/m17n/ M17n].


=== Input method module ===
=== Input method module ===


To obtain a better experience in Qt programs, install the {{AUR|fcitx-qt4}} and {{Pkg|fcitx-qt5}} input method modules as your need, or the {{Grp|fcitx-im}} group to install all of them. Without those modules, the input method may work on most applications but you may experience input method hang up, preview window screen location error or no preview error.  
To obtain a better experience in Qt programs, install {{AUR|fcitx-qt4}}, {{Pkg|fcitx-qt5}} or {{Pkg|fcitx-qt6}} input method modules as your need, or the {{Grp|fcitx-im}} group to install {{Pkg|fcitx}}, {{Pkg|fcitx-qt5}} and {{Pkg|fcitx-qt6}}. Without these modules, the input method may work on most applications but you may experience input method hang up, preview window screen location error or no preview error.  


Applications below do not use GTK/Qt input module:  
Applications below do not use GTK/Qt input module:  
Line 49: Line 61:


* {{Pkg|fcitx-ui-light}}, light UI for fcitx.
* {{Pkg|fcitx-ui-light}}, light UI for fcitx.
* {{Pkg|fcitx-table-extra}}, extra table.
* {{Pkg|fcitx-table-extra}} adds [[wikipedia:Cangjie_input_method|Cangjie]], [[wikipedia:Zhengma_method|Zhengma]], [[wikipedia:Boshiamy_method|Boshiamy]] support.
* {{Pkg|fcitx-table-other}}, tables for Latex, Emoji and others.  
* {{Pkg|fcitx-table-other}}, tables for Latex, Emoji and others.  
* [[#GUI configuration tools]]
* [[#GUI configuration tools]]
Line 56: Line 68:


== Usage ==
== Usage ==
{{Note|You need to have [[Fonts#Chinese, Japanese, Korean, Vietnamese|Chinese, Japanese, Korean or Vietnamese font]] installed to be able to enter the corresponding characters.}}
{{Note|You need to have [[Fonts#Chinese, Japanese, Korean, Vietnamese|Chinese, Japanese, Korean or Vietnamese font]] installed to be able to enter the corresponding characters.}}


=== Desktop Environment Autostart ===
=== Desktop Environment Autostart ===
If you are using any XDG compatible desktop environment such as [[KDE]], [[GNOME]], [[Xfce]], [[LXDE]], after you re-login, the autostart should work out of box. If not run the ''fcitx'' executable. To see if fcitx is working correctly, open an application and press {{ic|Ctrl+Space}} (the default shortcut for switching the input method) to invoke fcitx and input some words.


If fcitx failed to start with your desktop automatically or if you want to change the parameters to start fcitx, configure [[Autostarting#On_Xorg_startup|autostart]] or edit the {{ic|fcitx-autostart.desktop}} file in your {{ic|~/.config/autostart/}} directory (copy it from {{ic|/etc/xdg/autostart/}} if it doesn't exist yet).
If you are using any XDG compatible desktop environment such as [[KDE]], [[GNOME]], [[Xfce]], [[LXDE]], after you re-login, the autostart should work out of the box. If not, run the ''fcitx'' executable. To see if fcitx is working correctly, open an application and press {{ic|Ctrl+Space}} (the default shortcut for switching the input method) to invoke fcitx and input some words.
 
If fcitx failed to start with your desktop automatically or if you want to change the parameters to start fcitx, configure [[Autostarting#On Xorg startup|autostart]] or edit the {{ic|fcitx-autostart.desktop}} file in your {{ic|~/.config/autostart/}} directory (copy it from {{ic|/etc/xdg/autostart/}} if it does not exist yet).


When other input methods with xim support are also running, fcitx may fail to start due to an xim error. Ensure that no other input methods are running before you start fcitx.
When other input methods with xim support are also running, fcitx may fail to start due to an xim error. Ensure that no other input methods are running before you start fcitx.


Also please set the following environment variables to prefer IM modules for GTK/Qt applications.
Also please set the following environment variables to prefer IM modules for GTK/Qt applications.
For [[i3]] and [[Sway]] users, add {{ic|exec --no-startup-id fcitx -d
}} in your configuration file. [[fcitx5]] users should add {{ic|exec --no-startup-id fcitx5 -d}} instead.


=== Set environment variables for IM modules ===
=== Set environment variables for IM modules ===


[[Define]] the environment variables to register the input method modules. Without these variables, applications may fallback to XIM protocol, except for qt5 applications which don't have XIM support and require a IM module in place.
Set the following [[Environment variables#Graphical environment|environment variables]] to register the input method modules.
 
As a general recommendation, please define the following environment variables in {{ic|~/.pam_environment}} , it will be read by [[PAM|pam-env]] module for all logins, including both the X11 sessions and Wayland sessions. See {{ic|man 8 pam-env}} for details of its syntax and usage.
 
{{hc|~/.pam_environment|<nowiki>
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx</nowiki>
}}
 
In case you don't want to define the above variables in {{ic|~/.pam_environment}} for all your login sessions, please consider adding them to one of the start files for your X11 session.
Most [[Display manager]] such as [[GDM]] and [[SDDM]] will source {{ic|~/.xprofile}} file for X11 sessions (but not for Wayland sessions).
The syntax of {{ic|~/.xprofile}} file may depend on the specific [[Display manager]] and your login shell, consider the following example and modify it to suit your shell syntax:
 
{{hc|~/.xprofile|<nowiki>
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx</nowiki>
}}
 
 
For [[SLiM]] or [[startx]] users, they do NOT source {{ic|~/.xprofile}}, but instead run {{ic|~/.xinitrc}} to start your X11 session. Add the export lines to your {{ic|~/.xinitrc}} before the {{ic|exec YOUR_WM}} line:
 
{{hc|~/.xinitrc|<nowiki>
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
...
exec YOUR_WM</nowiki>
}}


GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx


Re-login or reboot to make these environment changes effective.
Without these variables, applications may fallback to XIM protocol, except for Qt5 applications which do not have XIM support and require an IM module in place.


If ''fcitx'' process does not start automatically, you might need to add {{ic|fcitx &}} in your {{ic|~/.xinitrc}}.
If ''fcitx'' process does not start automatically, you might need to add {{ic|fcitx &}} in your {{ic|~/.xinitrc}}.
If {{ic|fcitx &}} doesn't start, type {{ic|sleep 2}} after it
If {{ic|fcitx &}} does not start, type {{ic|sleep 2}} after it.


{{Note|
{{Note|
* Avoid {{ic|.bashrc}} for this, see [[GregsWiki:DotFiles]].
* Avoid {{ic|.bashrc}} for this, see [[GregsWiki:DotFiles]].
* If all Qt apps have problem with fcitx, run ''qtconfig'' (''qtconfig-qt4''), and go to the third tab, make sure ''fcitx'' is in the ''Default Input Method'' combo-box.
* If all Qt applications have problem with fcitx, run ''qtconfig'' (''qtconfig-qt4''), and go to the third tab, make sure ''fcitx'' is in the ''Default Input Method'' combo-box.
}}
}}


Line 122: Line 113:
{{Warning| Using XIM can sometimes cause problems including not being able to input, no cursor following, word selection window issue, application freeze on input method restart. For these XIM related problems, Fcitx cannot provide any fix or support. This is the same with any other input method framework, so please use the GTK and Qt input method modules instead of xim whenever possible}}
{{Warning| Using XIM can sometimes cause problems including not being able to input, no cursor following, word selection window issue, application freeze on input method restart. For these XIM related problems, Fcitx cannot provide any fix or support. This is the same with any other input method framework, so please use the GTK and Qt input method modules instead of xim whenever possible}}


{{Note|Gtk2 uses {{ic|/usr/lib/gtk-2.0/2.10.0/immodules.cache}} as immodule cache file since 2.24.20. If you have set {{ic|GTM_IM_MODULE_FILE}} environment variable or do not use install script of official packages to update the cache, please change/clear the environment variable and use {{ic|/usr/bin/gtk-query-immodules-2.0 --update-cache}} to update immodule cache.}}
{{Note|
* Gtk2 uses {{ic|/usr/lib/gtk-2.0/2.10.0/immodules.cache}} as immodule cache file since 2.24.20. If you have set {{ic|GTM_IM_MODULE_FILE}} environment variable or do not use install script of official packages to update the cache, please change/clear the environment variable and use {{ic|/usr/bin/gtk-query-immodules-2.0 --update-cache}} to update immodule cache.
* Qt5 applications no longer support XIM protocol as Qt4 did, and rely on IM modules entirely for communicating with fcitx.}}


{{Note| Qt5 applications no longer support XIM protocol as Qt4 did, and rely on IM modules entirely for communicating with fcitx.}}
== Configuration ==
 
==Configuration==


=== GUI configuration tools ===
=== GUI configuration tools ===
Line 161: Line 152:
=== Skins ===
=== Skins ===


You can download skins and extract them to one of the following directories, you can create the directory if it doesn't exist:
You can download skins and extract them to one of the following directories, you can create the directory if it does not exist:


  /usr/share/fcitx/skin  #Global settings
  /usr/share/fcitx/skin  #Global settings
Line 167: Line 158:


=== Cloud Pinyin configuration ===
=== Cloud Pinyin configuration ===
After installing the {{Pkg|fcitx-cloudpinyin}} input method, restart fcitx. If you could not find it in configuration GUI, enable advanced settings. The cloud query result will be added to current input method dictionary automatically.  
After installing the {{Pkg|fcitx-cloudpinyin}} input method, restart fcitx. If you could not find it in configuration GUI, enable advanced settings. The cloud query result will be added to current input method dictionary automatically.  


Line 176: Line 168:


== Tips and tricks ==
== Tips and tricks ==
===Clipboard Access===
 
=== Shortcut keys ===
 
Some commonly used default shortcut keys:
 
* {{ic|Ctrl+Space}} - activates the input method
* {{ic|Left Shift}} - temporarily switches to English
* {{ic|Ctrl+Shift}} - switch between input methods
* {{ic|-}}/{{ic|1==}} - page forward/backward
* {{ic|Shift+Space}} - Full-width, half-width switching
 
{{Note|You can modify these shortcut keys in the global configuration of the configuration interface.}}
 
=== Vim ===
 
If you often use Fcitx under Vim, you can install the {{AUR|vim-fcitx}} plugin, or add the following code to {{ic|~/.vimrc}}. When exiting insert mode, Fcitx is automatically closed, otherwise the reverse:
 
"##### auto fcitx  ###########
let g:input_toggle = 1
function! Fcitx2en()
    let s:input_status = system("fcitx-remote")
    if s:input_status == 2
      let g:input_toggle = 1
      let l:a = system("fcitx-remote -c")
    endif
endfunction
function! Fcitx2zh()
    let s:input_status = system("fcitx-remote")
    if s:input_status != 2 && g:input_toggle == 1
      let l:a = system("fcitx-remote -o")
      let g:input_toggle = 0
    endif
endfunction
set ttimeoutlen=150
"Exit insert mode
autocmd InsertLeave * call Fcitx2en()
"Enter insert mode
autocmd InsertEnter * call Fcitx2zh()
"##### auto fcitx end ######
 
{{Note|Due to calling external programs, this will significantly slow down the mapping that will repeatedly enter and exit insert mode. It is recommended to rewrite the relevant mapping, and use Vim with Python support in conjunction with fcitx.vim to improve efficiency.}}
 
=== Special symbols ===
 
Create {{ic|~/.config/fcitx/data/pySym.mb}}, the content of the file is as follows:
 
  #The first line with "#" is a comment
  #Format: coding symbol
  #Code can only be lowercase letters, after pinyin analysis, the longest is 10 (such as py is 2, pinyin is also 2)
  #Mathematics symbols
  sxfh +
  sxfh -
  sxfh <
  sxfh =
  sxfh >
  sxfh ±
  sxfh ×
  sxfh ÷
  sxfh ∈
  sxfh ∏
  sxfh ∑
  sxfh ∕
  sxfh √
  sxfh ∝
 
Enter a code directly to match the corresponding special symbol.
 
{{Note|The encoding can only be expressed with twenty-six lowercase letters; starting with v is invalid.}}
 
=== Clipboard Access ===
 
You can use fcitx to input text in you clipboard (as well as a short clipboard history and primary selection). The default trigger key is {{ic|Ctrl-;}}. You can change the trigger key as well as other options in the Clipboard addon configure page.
You can use fcitx to input text in you clipboard (as well as a short clipboard history and primary selection). The default trigger key is {{ic|Ctrl-;}}. You can change the trigger key as well as other options in the Clipboard addon configure page.


{{Note|This is NOT a clipboard manager, it doesn't hold the selection or change its content as what a clipboard manager is supposed to do. It can only be used to input from the clipboard.}}
{{Note|This is NOT a clipboard manager, it does not hold the selection or change its content as what a clipboard manager is supposed to do. It can only be used to input from the clipboard.}}


{{Warning| Some clients do not support multi-line input, so you may see the multi-line clipboard content pasted as a single line using fcitx-clipboard. This is either a bug or feature of the program being used and it is not something fcitx is able to help with.}}
{{Warning| Some clients do not support multi-line input, so you may see the multi-line clipboard content pasted as a single line using fcitx-clipboard. This is either a bug or feature of the program being used and it is not something fcitx is able to help with.}}


===fcitx-remote===
=== fcitx-remote ===
 
''fcitx-remote'' is a commandline tool that can be used to control the fcitx state. It is installed with the {{Pkg|fcitx}} package.
''fcitx-remote'' is a commandline tool that can be used to control the fcitx state. It is installed with the {{Pkg|fcitx}} package.


One option worth elaborating upon here is {{ic|fcitx-remote -s ''imname''}}, which switches to the input method identified by {{ic|''imname''}}. The correct {{ic|''imname''}} for an in use input method can be found by executing ''fcitx-diagnose'', and looking under the "## Input Methods:" section.
One option worth elaborating upon here is {{ic|fcitx-remote -s ''imname''}}, which switches to the input method identified by {{ic|''imname''}}. The correct {{ic|''imname''}} for an in use input method can be found by executing ''fcitx-diagnose'', and looking under the "## Input Methods:" section.


==Troubleshooting==
=== Input special character ===
 
See [[Fcitx5#Input special characters]], this content also applies to Fcitx.
 
== Troubleshooting ==


=== Disable or change ''Extra key for trigger input method'' [sic] ===
=== Disable or change ''Extra key for trigger input method'' [sic] ===
This setting is under the ''Global Config'' tab and defaults to ''SHIFT Both'', meaning that pressing ''either'' shift key will immediately change input methods. Although it should only apply when a shift key is pressed individually, it tends to randomly interrupt typing capital letters, selecting text with the keyboard, etc. while using standard keyboard input.
This setting is under the ''Global Config'' tab and defaults to ''SHIFT Both'', meaning that pressing ''either'' shift key will immediately change input methods. Although it should only apply when a shift key is pressed individually, it tends to randomly interrupt typing capital letters, selecting text with the keyboard, etc. while using standard keyboard input.


In addition, this setting may revert to default without warning at any time. To ensure fcitx's config cannot be modified, you must make fcitx's config file immutable: {{ic|chattr +i ~/.config/fcitx/config}} (as the root user).
In addition, this setting may revert to default without warning at any time. To ensure fcitx's configuration cannot be modified, you must make the file immutable: {{ic|chattr +i ~/.config/fcitx/config}} (as the root user).


=== Diagnose the problem ===
=== Diagnose the problem ===
If you have problems using fcitx, eg. Ctrl+Space fail to work in all applications, then the first thing you should try is to diagnose using {{ic|fcitx-diagnose}}.
If you have problems using fcitx, eg. Ctrl+Space fail to work in all applications, then the first thing you should try is to diagnose using {{ic|fcitx-diagnose}}.
The output of {{ic|fcitx-diagnose}} should contain the clue to most common problems.
The output of {{ic|fcitx-diagnose}} should contain the clue to most common problems.
Line 201: Line 272:


=== Emacs ===
=== Emacs ===
If your {{ic|LC_CTYPE}} is English, you may not be able to use input method in emacs due to an old emacs bug. You can set your {{ic|LC_CTYPE}} to something else such as {{ic|zh_CN.UTF-8}} before emacs starts to get rid of this problem.  
If your {{ic|LC_CTYPE}} is English, you may not be able to use input method in emacs due to an old emacs bug. You can set your {{ic|LC_CTYPE}} to something else such as {{ic|zh_CN.UTF-8}} before emacs starts to get rid of this problem.  


Note that the corresponding [[locale]] should be [[Locale#Generating locales|generated]] on your your system.
Note that the corresponding [[locale]] should be [[Locale#Generating locales|generated]] on your your system.


The default fontset will use `-*-*-*-r-normal--14-*-*-*-*-*-*-*' as basefont (in {{ic|src/xfns.c}}), if you do not have one matched (like terminus or 75dpi things, you can look the output of `xlsfonts'), XIM can not be activated.
The default fontset will use `-*-*-*-r-normal--14-*-*-*-*-*-*-*' as basefont (in {{ic|src/xfns.c}}), if you do not have one matched (like terminus or 75dpi things, you can look the output of `xlsfonts'), XIM can not be activated. According to [https://fcitx-im.org/wiki/FAQ#Emacs FAQ] and [[Fonts#Bitmap|Fonts]], it is likely that {{AUR|xorg-fonts-misc-otb}} is the one that should be installed since {{Pkg|xorg-fonts-misc}} no longer provides the required fontset.


==== Emacs Daemon ====
==== Emacs Daemon ====


If you are using [[Emacs#As_a_daemon|emacs daemon/client mode]], {{ic|LC_CTYPE}} should be set when starting the daemon. For example, by running emacs daemon with {{ic|1=LC_CTYPE=zh_CN.UTF-8 emacs --daemon}}.
If you are using [[Emacs#As a daemon|emacs daemon/client mode]], {{ic|LC_CTYPE}} should be set when starting the daemon. For example, by running emacs daemon with {{ic|1=LC_CTYPE=zh_CN.UTF-8 emacs --daemon}}.


If starting emacs daemon from [[systemd]], [[Systemd#Editing provided_units|set]] {{ic|1=Environment="LC_CTYPE=zh_CN.UTF-8" "XMODIFIERS=@im=fcitx"}} in the unit file.
If starting emacs daemon from [[systemd]], [[Systemd#Editing provided units|set]] {{ic|1=Environment="LC_CTYPE=zh_CN.UTF-8" "XMODIFIERS=@im=fcitx"}} in the unit file.


({{ic|XMODIFIERS}} may need to be set explicitly here as systemd doesn't load {{ic|.xprofile}}. Check the {{ic|initial-environment}} variable in emacs to verify both variables are set correctly.)
({{ic|XMODIFIERS}} may need to be set explicitly here as systemd does not load {{ic|.xprofile}}. Check the {{ic|initial-environment}} variable in emacs to verify both variables are set correctly.)


=== Ctrl+Space fail to work in GTK programs ===
=== Ctrl+Space fail to work in GTK programs ===
Line 219: Line 291:
This problem sometimes happens especially when the locale is set as English. Please make sure your {{ic|GTK_IM_MODULE}} is set correctly.
This problem sometimes happens especially when the locale is set as English. Please make sure your {{ic|GTK_IM_MODULE}} is set correctly.


See also [http://fcitx-im.org/wiki/FAQ#When_use_Ctrl_.2B_Space.2C_Fcitx_cannot_be_triggered_on FAQ]
See also [https://fcitx-im.org/wiki/FAQ#When_use_Ctrl_.2B_Space.2C_Fcitx_cannot_be_triggered_on FAQ]


If you have set the {{ic|*_IM_MODULE}} environment variables to fcitx but cannot activate fcitx, please check if you have installed the corresponding input method modules.
If you have set the {{ic|*_IM_MODULE}} environment variables to fcitx but cannot activate fcitx, please check if you have installed the corresponding input method modules.
Line 225: Line 297:
Some programs can only use xim, if you are using these programs, please make sure your {{ic|XMODIFIERS}} is set properly and be aware of the problems you may have. These programs include all programs that are not using GTK or Qt (e.g. programs that use tk, motif, or xlib directly), emacs, opera, openoffice, libreoffice, skype.
Some programs can only use xim, if you are using these programs, please make sure your {{ic|XMODIFIERS}} is set properly and be aware of the problems you may have. These programs include all programs that are not using GTK or Qt (e.g. programs that use tk, motif, or xlib directly), emacs, opera, openoffice, libreoffice, skype.


If you cannot enable fcitx in ''gnome-terminal'' under Gnome and the above way doesn't work, try:
If you cannot enable fcitx in ''gnome-terminal'' under Gnome and the above way does not work, try:


  $ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule':<'fcitx'>}"
  $ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule':<'fcitx'>}"
Line 243: Line 315:
=== fcitx and KDE ===
=== fcitx and KDE ===


For some reasons, [[KDE]] doesn't handle keyboard layouts properly. For example, if you switch from US (English) to LT (Lithuanian), all numbers on the keyboard should produce Lithuanian letters, but they still produce numbers as the output. This can be fixed by these steps:
For some reasons, [[KDE]] does not handle keyboard layouts properly. For example, if you switch from US (English) to LT (Lithuanian), all numbers on the keyboard should produce Lithuanian letters, but they still produce numbers as the output. This can be fixed by these steps:


# Turn off ''fcitx'' if it is running in the background.
# Turn off ''fcitx'' if it is running in the background.
Line 259: Line 331:
For instance, in XMind, when the user presses {{ic|Enter}} to create a node, input method is always switched to English, and has to be switched back to Chinese manually.
For instance, in XMind, when the user presses {{ic|Enter}} to create a node, input method is always switched to English, and has to be switched back to Chinese manually.


To fix this issue, open the ''fcitx'' GUI configuration tool (provided by {{Pkg|fcitx-configtool}}), switch to tab ''Global Config'', in dropdown menu ''Share State Among Window'', select ''PerProgram'' or ''All''.
To fix this issue, open the fcitx GUI configuration tool (provided by {{Pkg|fcitx-configtool}}), switch to tab ''Global Config'', in dropdown menu ''Share State Among Window'', select ''PerProgram'' or ''All''.


=== xmodmap settings being overwritten ===
=== xmodmap settings being overwritten ===
Line 266: Line 338:
Since 4.2.7, Fcitx will try to load {{ic|~/.Xmodmap}} if it exists.
Since 4.2.7, Fcitx will try to load {{ic|~/.Xmodmap}} if it exists.


For more details on how you can save your xmodmap changes see [http://fcitx-im.org/wiki/FAQ#xmodmap_settings_being_overwritten FAQ]
For more details on how you can save your xmodmap changes see [https://fcitx-im.org/wiki/FAQ#xmodmap_settings_being_overwritten FAQ]
 
==== Fcitx and setxkbmap ====
 
If you are using ''setxkbmap'' for another language, then (as per above) fcitx can overwrite them and even prevent from switching to that language in certain applications (e.g. QuteBrowser).
 
If you would like to prevent that and manage your [[xmodmap]] layouts independently from fcitx then follow these steps:
# Open the fcitx GUI configuration tool (provided by {{Pkg|fcitx-configtool}})
# Switch to tab ''Addon''
# Select ''Advanced''
# Search for ''xkb''#
# Select ''X Keyboards Integration''
# Click ''Configure''
# Unselect ''Allow to Override System XKB Settings''
# Click ''OK''
 
=== Fcitx preedit box is too small with HiDPI ===
 
See [[HiDPI#Fcitx]]


== See also ==
== See also ==


* [https://gitlab.com/fcitx/fcitx Fcitx GitLab]
* [https://gitlab.com/fcitx/fcitx Fcitx GitLab]
* [http://fcitx-im.org/ Fcitx Wiki]
* [https://fcitx-im.org/ Fcitx Wiki]

Latest revision as of 14:30, 7 October 2023

Fcitx is a lightweight input method framework aimed at providing environment independent language support for Linux. It supports a lot of different languages and also provides many useful non-CJK features.

Warning: Fcitx is now in maintenance mode. It is recommended to use Fcitx5 instead.

Installation

Install the fcitx package.

Input method engines

Fcitx provides built-in input methods for Chinese Pinyin and table-based input (for example Wubi).

Depending on the language you wish to type, other input method engines are available:

Chinese

Japanese

  • fcitx-anthy, a popular Japanese input engine. However, it is not actively developed anymore.
  • fcitx-mozc, based on Mozc, the Open Source Edition of Google Japanese Input.
  • fcitx-kkc, a Japanese Kana Kanji input engine, based on libkkc.
  • fcitx-skk, a Japanese Kana Kanji input engine, based on libskk.

Other languages

Input method module

To obtain a better experience in Qt programs, install fcitx-qt4AUR, fcitx-qt5 or fcitx-qt6 input method modules as your need, or the fcitx-im group to install fcitx, fcitx-qt5 and fcitx-qt6. Without these modules, the input method may work on most applications but you may experience input method hang up, preview window screen location error or no preview error.

Applications below do not use GTK/Qt input module:

  • Applications use Tk, motif or xlib
  • Emacs, Opera, OpenOffice, LibreOffice, Skype, Wine, Java, Xterm, urxvt, WPS

Others

Others packages (including git version) are also available in the AUR. All components of fcitx will requires fcitx to restart after install.

Usage

Note: You need to have Chinese, Japanese, Korean or Vietnamese font installed to be able to enter the corresponding characters.

Desktop Environment Autostart

If you are using any XDG compatible desktop environment such as KDE, GNOME, Xfce, LXDE, after you re-login, the autostart should work out of the box. If not, run the fcitx executable. To see if fcitx is working correctly, open an application and press Ctrl+Space (the default shortcut for switching the input method) to invoke fcitx and input some words.

If fcitx failed to start with your desktop automatically or if you want to change the parameters to start fcitx, configure autostart or edit the fcitx-autostart.desktop file in your ~/.config/autostart/ directory (copy it from /etc/xdg/autostart/ if it does not exist yet).

When other input methods with xim support are also running, fcitx may fail to start due to an xim error. Ensure that no other input methods are running before you start fcitx.

Also please set the following environment variables to prefer IM modules for GTK/Qt applications.

For i3 and Sway users, add exec --no-startup-id fcitx -d in your configuration file. fcitx5 users should add exec --no-startup-id fcitx5 -d instead.

Set environment variables for IM modules

Set the following environment variables to register the input method modules.

GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx

Without these variables, applications may fallback to XIM protocol, except for Qt5 applications which do not have XIM support and require an IM module in place.

If fcitx process does not start automatically, you might need to add fcitx & in your ~/.xinitrc. If fcitx & does not start, type sleep 2 after it.

Note:
  • Avoid .bashrc for this, see GregsWiki:DotFiles.
  • If all Qt applications have problem with fcitx, run qtconfig (qtconfig-qt4), and go to the third tab, make sure fcitx is in the Default Input Method combo-box.

XIM

Optionally, you can use the X Input Method (XIM) in your GTK and/or Qt programs without installing the above modules in which case you need to change the corresponding lines above as following:

GTK_IM_MODULE=xim
QT_IM_MODULE=xim

If you change it in ~/.xprofile or ~/.xinitrc, add export.

Warning: Using XIM can sometimes cause problems including not being able to input, no cursor following, word selection window issue, application freeze on input method restart. For these XIM related problems, Fcitx cannot provide any fix or support. This is the same with any other input method framework, so please use the GTK and Qt input method modules instead of xim whenever possible
Note:
  • Gtk2 uses /usr/lib/gtk-2.0/2.10.0/immodules.cache as immodule cache file since 2.24.20. If you have set GTM_IM_MODULE_FILE environment variable or do not use install script of official packages to update the cache, please change/clear the environment variable and use /usr/bin/gtk-query-immodules-2.0 --update-cache to update immodule cache.
  • Qt5 applications no longer support XIM protocol as Qt4 did, and rely on IM modules entirely for communicating with fcitx.

Configuration

GUI configuration tools

fcitx provides a KDE configuration module (kcm-fcitx) and a GTK3 configuration tool (fcitx-configtool).

Run fcitx-config-gtk3 after fcitx-configtool is installed. Unset Only Show Current Language if you want to enable an input method for a different language.

Stop fcitx manually before changing configuration, or the change may be lost.

In order to enable spell checking, press Ctrl+Alt+h when fcitx is on an input method provided by fcitx-keyboard.

Input methods configuration

You can add/remove input methods in the GUI tools. Note that the search is case sensitive.

The first set input method is the inactive state, while all the rest will be active states. You generally want the inactive state to be one of the Keyboard options (e.g. "Keyboard - English (US)"). These options just input based on the keyboard layout in the name.

Under Global Config, the Trigger Input Method shortcut will only switch between the inactive and last used active state. The Scroll between Input Methods will by default only scroll between different active states, but can also be set to include the inactive state in the advanced settings. Furthermore, the Scroll between Input Methods shortcut has to be pressed in order, e.g. ALT_SHIFT will only activate if alt is pressed before shift.

Configuration settings for IME's can be found by by setting the keyboard to the desired IME and right-clicking the tray icon.

Change default UI

Fcitx support kimpanel protocol to provide better desktop integration.

  • Gnome-Shell: You can install kimpanel from extensions.gnome.org or gnome-shell-extension-kimpanel-gitAUR, which provides a similar user experience as ibus-gjs.
  • KDE: kimtoy could use skin from Sogou and fcitx.

Extend pinyin dictionary

Pinyin dictionary is located at ~/.config/fcitx/pinyin. File pybase.mb is for single characters and file pyphrase.mb defines pinyin phrases. To extend them, put your file into /usr/share/fcitx/pinyin and restart fcitx.

Skins

You can download skins and extract them to one of the following directories, you can create the directory if it does not exist:

/usr/share/fcitx/skin   #Global settings
~/.config/fcitx/skin    #User settings

Cloud Pinyin configuration

After installing the fcitx-cloudpinyin input method, restart fcitx. If you could not find it in configuration GUI, enable advanced settings. The cloud query result will be added to current input method dictionary automatically.

If your network prevents you from accessing Google, change Cloud Pinyin source to Baidu.

The query result from cloud will list as secondary candidate by default and it is configurable. If the result already exists, only one item is shown.

Note: Set query result as first candidate is not recommend because the dictionary order will be changed if query returns an empty result

Tips and tricks

Shortcut keys

Some commonly used default shortcut keys:

  • Ctrl+Space - activates the input method
  • Left Shift - temporarily switches to English
  • Ctrl+Shift - switch between input methods
  • -/= - page forward/backward
  • Shift+Space - Full-width, half-width switching
Note: You can modify these shortcut keys in the global configuration of the configuration interface.

Vim

If you often use Fcitx under Vim, you can install the vim-fcitxAUR plugin, or add the following code to ~/.vimrc. When exiting insert mode, Fcitx is automatically closed, otherwise the reverse:

"##### auto fcitx  ###########
let g:input_toggle = 1
function! Fcitx2en()
   let s:input_status = system("fcitx-remote")
   if s:input_status == 2
      let g:input_toggle = 1
      let l:a = system("fcitx-remote -c")
   endif
endfunction

function! Fcitx2zh()
   let s:input_status = system("fcitx-remote")
   if s:input_status != 2 && g:input_toggle == 1
      let l:a = system("fcitx-remote -o")
      let g:input_toggle = 0
   endif
endfunction

set ttimeoutlen=150
"Exit insert mode
autocmd InsertLeave * call Fcitx2en()
"Enter insert mode
autocmd InsertEnter * call Fcitx2zh()
"##### auto fcitx end ######
Note: Due to calling external programs, this will significantly slow down the mapping that will repeatedly enter and exit insert mode. It is recommended to rewrite the relevant mapping, and use Vim with Python support in conjunction with fcitx.vim to improve efficiency.

Special symbols

Create ~/.config/fcitx/data/pySym.mb, the content of the file is as follows:

 #The first line with "#" is a comment
 #Format: coding symbol
 #Code can only be lowercase letters, after pinyin analysis, the longest is 10 (such as py is 2, pinyin is also 2)
 #Mathematics symbols
 sxfh +
 sxfh -
 sxfh <
 sxfh =
 sxfh >
 sxfh ±
 sxfh ×
 sxfh ÷
 sxfh ∈
 sxfh ∏
 sxfh ∑
 sxfh ∕
 sxfh √
 sxfh ∝

Enter a code directly to match the corresponding special symbol.

Note: The encoding can only be expressed with twenty-six lowercase letters; starting with v is invalid.

Clipboard Access

You can use fcitx to input text in you clipboard (as well as a short clipboard history and primary selection). The default trigger key is Ctrl-;. You can change the trigger key as well as other options in the Clipboard addon configure page.

Note: This is NOT a clipboard manager, it does not hold the selection or change its content as what a clipboard manager is supposed to do. It can only be used to input from the clipboard.
Warning: Some clients do not support multi-line input, so you may see the multi-line clipboard content pasted as a single line using fcitx-clipboard. This is either a bug or feature of the program being used and it is not something fcitx is able to help with.

fcitx-remote

fcitx-remote is a commandline tool that can be used to control the fcitx state. It is installed with the fcitx package.

One option worth elaborating upon here is fcitx-remote -s imname, which switches to the input method identified by imname. The correct imname for an in use input method can be found by executing fcitx-diagnose, and looking under the "## Input Methods:" section.

Input special character

See Fcitx5#Input special characters, this content also applies to Fcitx.

Troubleshooting

Disable or change Extra key for trigger input method [sic]

This setting is under the Global Config tab and defaults to SHIFT Both, meaning that pressing either shift key will immediately change input methods. Although it should only apply when a shift key is pressed individually, it tends to randomly interrupt typing capital letters, selecting text with the keyboard, etc. while using standard keyboard input.

In addition, this setting may revert to default without warning at any time. To ensure fcitx's configuration cannot be modified, you must make the file immutable: chattr +i ~/.config/fcitx/config (as the root user).

Diagnose the problem

If you have problems using fcitx, eg. Ctrl+Space fail to work in all applications, then the first thing you should try is to diagnose using fcitx-diagnose. The output of fcitx-diagnose should contain the clue to most common problems. Providing the output of it will also help when you consult other people(eg. in IRC or forums).

Emacs

If your LC_CTYPE is English, you may not be able to use input method in emacs due to an old emacs bug. You can set your LC_CTYPE to something else such as zh_CN.UTF-8 before emacs starts to get rid of this problem.

Note that the corresponding locale should be generated on your your system.

The default fontset will use `-*-*-*-r-normal--14-*-*-*-*-*-*-*' as basefont (in src/xfns.c), if you do not have one matched (like terminus or 75dpi things, you can look the output of `xlsfonts'), XIM can not be activated. According to FAQ and Fonts, it is likely that xorg-fonts-misc-otbAUR is the one that should be installed since xorg-fonts-misc no longer provides the required fontset.

Emacs Daemon

If you are using emacs daemon/client mode, LC_CTYPE should be set when starting the daemon. For example, by running emacs daemon with LC_CTYPE=zh_CN.UTF-8 emacs --daemon.

If starting emacs daemon from systemd, set Environment="LC_CTYPE=zh_CN.UTF-8" "XMODIFIERS=@im=fcitx" in the unit file.

(XMODIFIERS may need to be set explicitly here as systemd does not load .xprofile. Check the initial-environment variable in emacs to verify both variables are set correctly.)

Ctrl+Space fail to work in GTK programs

This problem sometimes happens especially when the locale is set as English. Please make sure your GTK_IM_MODULE is set correctly.

See also FAQ

If you have set the *_IM_MODULE environment variables to fcitx but cannot activate fcitx, please check if you have installed the corresponding input method modules.

Some programs can only use xim, if you are using these programs, please make sure your XMODIFIERS is set properly and be aware of the problems you may have. These programs include all programs that are not using GTK or Qt (e.g. programs that use tk, motif, or xlib directly), emacs, opera, openoffice, libreoffice, skype.

If you cannot enable fcitx in gnome-terminal under Gnome and the above way does not work, try:

$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule':<'fcitx'>}"

Buildin Chinese Pinyin Default NOT ACTIVE

If your locale is en_US.UTF-8, fcitx did NOT enable the buildin Chinese Pinyin input method by default. There is only fcitx-keyboard-us input method enabled. You can get a notice by fcitx-diagnose command like this:

   ## Input Methods:
       1.  Found 1 enabled input methods:
               fcitx-keyboard-us
       2.  Default input methods:
           **You only have one input method enabled, please add a keyboard input method as the first one and your main input method as the second one.**

Then you should add Pinyin or Shuangpin input method to actived input methods by the GUI configure tool.

fcitx and KDE

For some reasons, KDE does not handle keyboard layouts properly. For example, if you switch from US (English) to LT (Lithuanian), all numbers on the keyboard should produce Lithuanian letters, but they still produce numbers as the output. This can be fixed by these steps:

  1. Turn off fcitx if it is running in the background.
  2. Disable stuff related to KDE:
    1. At System settings > Input devices > Layouts (tab) make sure that Configure layouts is unchecked.
    2. At System settings > Input devices > Advanced (tab) make sure that Configure keyboard options is unchecked.
  3. Start fcitx to start it. You can close the terminal - fcitx will still be running in the background.
  4. Set up your needed layouts (right click on the system tray icon, then Configure).
  5. Right click on the system tray icon, then Exit

At this point you should have working layouts, native KDE layouts switch icon should appear and you can switch them by mouse scroll or click on it.

Input method switched to English unintentionally

For instance, in XMind, when the user presses Enter to create a node, input method is always switched to English, and has to be switched back to Chinese manually.

To fix this issue, open the fcitx GUI configuration tool (provided by fcitx-configtool), switch to tab Global Config, in dropdown menu Share State Among Window, select PerProgram or All.

xmodmap settings being overwritten

fcitx controls keyboard layout, so your xmodmap settings will be overwritten. Since 4.2.7, Fcitx will try to load ~/.Xmodmap if it exists.

For more details on how you can save your xmodmap changes see FAQ

Fcitx and setxkbmap

If you are using setxkbmap for another language, then (as per above) fcitx can overwrite them and even prevent from switching to that language in certain applications (e.g. QuteBrowser).

If you would like to prevent that and manage your xmodmap layouts independently from fcitx then follow these steps:

  1. Open the fcitx GUI configuration tool (provided by fcitx-configtool)
  2. Switch to tab Addon
  3. Select Advanced
  4. Search for xkb#
  5. Select X Keyboards Integration
  6. Click Configure
  7. Unselect Allow to Override System XKB Settings
  8. Click OK

Fcitx preedit box is too small with HiDPI

See HiDPI#Fcitx

See also