网上找了很多教程,都是设置环境变量,本身思路没问题。
只不过有问题的是,环境变量是基于会话的。大多数教程设置环境变量的方法需要启动一个 shell 进程才能加载。
而用户的窗口进程是系统启动的时候就已经加载了,肯定不会去加载 shell 的环境变量。
在用户配置中写入环境变量
直接把环境变量写进用户的配置文件就可以解决这个问题。
在 /etc/systemd/user.conf
中加入一行DefaultEnvironment
就可以解决这个问题
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the user.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See systemd-user.conf(5) for details.
[Manager]
DefaultEnvironment=XMODIFIERS="@im=fcitx" XIM=fcitx XIM_PROGRAM=fcitx GTK_IM_MODULE=fcitx QT_IM_MODULE=fcitx
#QT_QPA_PLATFORM=wayland
#LogLevel=info
#LogTarget=console
#LogColor=yes
#LogLocation=no
#LogTime=no
#SystemCallArchitectures=
#TimerSlackNSec=
#StatusUnitFormat=description
#DefaultTimerAccuracySec=1min
#DefaultStandardOutput=inherit
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
#DefaultTimeoutAbortSec=
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5
#DefaultEnvironment=
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=
#DefaultLimitSTACK=
#DefaultLimitCORE=
#DefaultLimitRSS=
#DefaultLimitNOFILE=
#DefaultLimitAS=
#DefaultLimitNPROC=
#DefaultLimitMEMLOCK=
#DefaultLimitLOCKS=
#DefaultLimitSIGPENDING=
#DefaultLimitMSGQUEUE=
#DefaultLimitNICE=
#DefaultLimitRTPRIO=
#DefaultLimitRTTIME=
pyqt5不能调用fcitx5
这个问题的根源在于pyqt5没有正确加载fcitx5的库文件,找到文件复制到对应的文件夹就可以了。
我两次处理这个问题的过程都不一样,但是核心解决思路是一样的。
具体过程问问百度吧。