如何在win11上的wslg中使用fcitx?

如何在win11上的wslg中使用fcitx?

WSLgWindows 11可以运行LinuxGUI。

LinuxGUI中的书写方法(例如gedit)与 Windows 输入法不同

我安装了fcitx,但是有几个问题:

  1. 该图标未显示在Windows工具栏面板上,因此无法通过单击图标来切换不同的输入法

  2. 有些键盘无法使用。WubiPolish键盘可以工作,但是HebrewGreekRussian仍在使用Polish字母

  3. 如何自动启动?启动GUIfcitx时,我应该手动启动,这很无聊。所以我尝试安装桌面,但桌面无法填满整个屏幕(我会在LinuxfcitxLinuxLxQt分开岗位为了这)。

那么你能帮我解决这些问题吗?

答案1

1)fcitx5使用以下 bash 命令安装:

# https://forum.ubuntu.org.cn/viewtopic.php?t=491625
# 安装fcitx5
sudo apt remove --purge ibus*

sudo apt update
sudo apt install fcitx5 \
fcitx5-frontend-gtk2 \
fcitx5-frontend-gtk3 \
fcitx5-chinese-addons  #contain wubi
# fcitx5自启动
sudo tee /etc/X11/Xsession.d/73fcitx5_start > /dev/null << 'EOF'
#!/bin/sh

if [ -x /usr/bin/fcitx5 ] && [ -x /usr/bin/im-config ]; then
    if [ ! -f $HOME/.xinputrc ]; then
        /usr/bin/im-config -n fcitx5 && export XMODIFIERS=@im=fcitx || true
    fi

    if [ "$XMODIFIERS" = "@im=fcitx" ]; then
        if [ -f /usr/lib/*/gtk-2.0/*/immodules/im-fcitx5.so ] && [ -f /usr/lib/*/gtk-3.0/*/immodules/im-fcitx5.so ]; then
            export GTK_IM_MODULE=fcitx
        fi
        if [ -f /usr/lib/*/qt4/plugins/inputmethods/qtim-fcitx5.so ]; then
            export QT4_IM_MODULE=fcitx
        fi
        if [ -f /usr/lib/*/qt5/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so ]; then
            export QT_IM_MODULE=fcitx
            fi
        fi
    if [ -x /usr/bin/fcitx5-remote ]; then
        /usr/bin/fcitx5-remote > /dev/null || /usr/bin/fcitx5
    fi
    if [ -x /usr/bin/im-launch ]; then
        STARTUP="/usr/bin/im-launch $STARTUP"
    fi
fi
EOF
# 删除用户ibus输入法列表
gsettings set org.gnome.desktop.input-sources sources "[]"
# 选择fcitx5输入法
im-config -n fcitx5
# 生成配置文件
mkdir -p ~/.config/fcitx5
cat > ~/.config/fcitx5/profile << 'EOF'
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=pinyin

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=pinyin
# Layout
Layout=

[GroupOrder]
0=Default
EOF
# 安装并启用gnome-shell-extension-kimpanel扩展
wget https://extensions.gnome.org/extension-data/kimpanelkde.org.v55.shell-extension.zip
gnome-extensions install kimpanelkde.org.v55.shell-extension.zip
gnome-extensions enable [email protected]


2)启动终端时获取 FCITX5

目前我只解决了一半这个问题。

根据这个帖子,问题在于wayland,因此需要在.profile或中添加一些行.bashrc

# https://yanqiyu.info/2021/06/29/wslg-gpu/
daemonize -e /tmp/fcitx5.log -o /tmp/fcitx5.log -p /tmp/fcitx5.pid -l /tmp/fcitx5.pid -a /usr/bin/fcitx5 --disable=wayland
export INPUT_METHOD=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

但我的WSL2使用top显示fcitx5系统启动时正在运行,但是我就是无法激活它!!

如果有人能告诉我那里出了什么问题,我将不胜感激。

所以现在我无法将这些行放入.profile.bashrc。我放入了一个名为的文件source_fcitx5.sh,需要手动激活fcitx5

source source_fcitx5.sh

答案2

我当前的系统是:

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.19045.4170

PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

以下是新版本的解决方案:

# https://forum.ubuntu.org.cn/viewtopic.php?t=491625

## INSTALL FCITX5
sudo apt update

yes Y | sudo apt install fcitx5 \
fcitx5-frontend-gtk2 \
fcitx5-frontend-gtk3 \
fcitx5-frontend-gtk4 \
fcitx5-frontend-qt5 \
fcitx5-frontend-qt6 \
fcitx5-config-qt \
fcitx5-chinese-addons -y #contain wubi

## DELETE IBUS 
#sudo apt remove --purge ibus*
#gsettings set org.gnome.desktop.input-sources sources "[]"

## CHOOSE FCITX5
yes Y | sudo apt install zenity im-config
im-config -n fcitx5
# If im-config cannot save, manually configure the priority to fcitx5 in: sudo vim /etc/default/im-config
# #Always start highest priority IM
# IM_CONFIG_DEFAULT_MODE=fcitx5

## CONFIGURATION
mkdir -p ~/.config/fcitx5
cat > ~/.config/fcitx5/profile << 'EOF'
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=pl
# Default Input Method
DefaultIM=wbx

[Groups/0/Items/0]
# Name
Name=keyboard-pl
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=wbx
# Layout
Layout=

[Groups/0/Items/2]
# Name
Name=keyboard-il
# Layout
Layout=

[Groups/0/Items/3]
# Name
Name=keyboard-gr
# Layout
Layout=

[GroupOrder]
0=Default
EOF

## AUTOSTART
# https://zahui.fan/posts/81886814/
sudo tee -a /etc/profile <<-'EOF'
/usr/bin/fcitx5 --disable=wayland -d --verbose '*'=0
export INPUT_METHOD=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export SDL_IM_MODULE=fcitx
export GLFW_IM_MODULE=ibus
EOF

相关内容