背景:
筆記本Thinkpad E450,操作系統Ubuntu 24.04.2 LTS,Chrome瀏覽器版本135.0.7049.114-1,Edge瀏覽器版本131.0.2903.99-1,輸入法Sogou版本4.2.1.145
現象:
- **正常場景**:Edge中可通過Ctrl+Space切換搜狗輸入法 ?
- **異常場景**:Chrome中Ctrl+Space無響應,輸入法狀態欄不出現
似乎在Typora中也有相同的問題,不能使用sogou輸入法。
分析過程:
之前sogou輸入法在低版本chrome瀏覽器正常使用,后來升級chrome版本,就不工作了。網上提供的解決方案是嘗試降低chrome瀏覽器版本,獲得兼容并可繼續在chrome browser中使用sogou輸入法。
升級chrome版本是不可避免的過程,如果不升級也會帶來其他的問題,因而不考慮降版本。
當前狀態:
已確認問題:
? GTK3未編譯Fcitx輸入法模塊
? IBus守護進程搶占輸入法總線
1)查詢谷歌版本
dpkg -l | grep google
andy@ThinkPad:~/Desktop$ dpkg -l | grep google
ii ?google-chrome-stable ? ? ? ? ? ? ? ? ? ? ? ? ? 135.0.7049.114-1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?amd64 ? ? ? ?The web browser from Google
2)問題追蹤
1.im-config -l
2.fcitx-diagnose
**Cannot find `gtk-query-immodules` for gtk 3**
**Cannot find fcitx im module for gtk 3.**
3.google-chrome --gtk-im-module=fcitx --enable-logging=stderr --v=1
google-chrome log>>
(chrome --gtk-im-module=fcitx --enable-logging=stderr --v=1:5686): Gtk-WARNING **: 13:57:10.217: No IM module matching GTK_IM_MODULE=fcitx found
[5686:5686:0505/135710.217860:VERBOSE1:input_method_context_impl_gtk.cc(95)] Using GTK IM context: ibus
存在2個問題:
No IM module matching GTK_IM_MODULE=fcitx found
Using GTK IM context: ibus
支持事項:
1)安裝gtk3,gtk2已經過時了。
sudo apt install libgtk-3-dev gtk-doc-tools
gtk-query-settings --summary
2)環境變量設置
# 全局生效(需管理員權限)
sudo cat <<EOF>> /etc/environment
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
EOF
# 用戶級生效
echo 'export GTK_IM_MODULE=fcitx' >> ~/.bashrc
echo 'export QT_IM_MODULE=fcitx' >> ~/.bashrc
cat <<EOF>> ~/.profile
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
EOF
source ~/.profile
3)緩存重建
dpkg -S gtk-query-immodules-3.0
sudo /usr/lib/x86_64-linux-gnu/libgtk-3-0t64/gtk-query-immodules-3.0 --update-cache
4)重啟,打開chrome或typora測試,sogou恢復正常使用。
andy@ThinkPad:~/Desktop$ fcitx-diagnose | grep -E "GTK|Active"
1. ?gtk - `${GTK_IM_MODULE}`:
? ? Environment variable GTK_IM_MODULE is set to "fcitx" correctly.
?