fcitx輸入法在wps、wineqq中失靈問題的解決

最近由Mint轉到了Open SUSE下,各類折騰。bash

眼看着已經摺騰差很少了,今天又遇到個問題:app

在Wineqq以及wps下,fcitx輸入法打不開,無法輸入中文。測試

這就很是坑了,這兩個軟件輸入不了中文,基本就至關於沒安裝。因而乎上網各類查。網上查到的教程上大部分都是說這是由於有幾個環境變量沒有配置正確形成的。按照網上的方法,分別在~/.bashrc ~/.xprofile /etc/profile 文件中添加了以下代碼:spa

export XIM="fcitx"
export XIM_PROGRAM="fcitx"
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"

重啓,發現仍是很差使。命令行

偶然發現,若是在命令行中運行wps等命令,fcitx就好使。初步懷疑是上面配置的環境變量在雙擊運行的時候未生效形成的。code

寫一腳本,測試,代碼以下:教程

#!/usr/bin/sh
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"
/usr/bin/wpp

保存爲wpp.sh,將桌面上的wps-office-wpp.desktop目標地址改爲該腳本以後,運行,好使了。
肯定是環境變量的問題了。ip

接下來,就能夠對wps、wineqq作一下小改動。ci

Wine QQget

wineqq的運行腳本是/opt/longene/tm2013/tm2013.sh (我安裝的是tm2013,qq2013同理)。編輯此腳本,在最開始加入

export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"

保存

WPS

對於wps,雙擊桌面圖標運行的是/usr/bin/wps(wpp,et),因此須要用一個腳本,在執行程序以前,配置一下環境變量。實際腳本跟上面的測試腳本有一點點區別:

#!/usr/bin/sh
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"
/usr/bin/wpp "$1"   //modify:13-12-18

之因此將可執行文件後面加了個參數,是由於.desktop文件調用可執行文件的時候會傳一個%f參數給可執行文件,咱們如今讓它傳給咱們的腳本,再由咱們的腳本調用

將調用wps、wpp、et的腳本都寫好後,放到/opt/kingsoft/wps-office/office6/目錄中,而後分別修改/usr/share/applications/目錄中的wps-office-wps.desktop wps-office-wpp.desktop wps-office-et.desktop作以下修改(以wpp爲例,其他相似):

#!/usr/bin/env xdg-open
[Desktop Entry]
Comment=Use Kingsoft Presentation to edit and play presentations.
Comment[zh_CN]=使用 WPS 演示編輯、播放演示文稿
#Exec=/usr/bin/wpp %f
Exec=/opt/kingsoft/wps-office/office6/wpp.sh %f   ####將上一行代碼註釋掉,增長本行
GenericName=Kingsoft Presentation
GenericName[zh_CN]=WPS 演示
MimeType=application/wps-office.dps;application/wps-office.dpt;application/wps-office.ppt;application/wps-office.pot;application/vnd.ms-powerpoint;application/vnd.mspowerpoint;application/mspowerpoint;application/powerpoint;application/x-mspowerpoint;application/wps-office.pptx;application/wps-office.potx;
Name=Kingsoft Presentation
Name[zh_CN]=WPS 演示
StartupNotify=false
Terminal=false
Type=Application
Categories=Office;Presentation;Qt;
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
Icon=wps-office-wppmain
InitialPreference=3

運行wps,成功


雖然問題是解決了,但如今仍是有幾個問題,求高手指點:

  1. 在.desktop腳本中 %f 參數是什麼意思

2. 爲何在相應文件中配置了環境變量,在終端以外卻很差使?

2013/12/18

  1. 更正bug:腳本中的最後一行應改成/usr/bin/wpp "$1"

  2. %f的做用 官方手冊

%f A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax.

相關文章
相關標籤/搜索