sudo apt update && sudo apt upgrade -y
# In the current issue, it is set to `zh_CN.UTF-8`.
sudo dpkg-reconfigure locales
# Before executing `echo $LANG`, open a new Ubuntu WSL shell. Make sure `echo $LANG` outputs `zh_CN.UTF-8`.
echo $LANG
# I would say this will provide a Chinese GUI for `ibus-setup`.
sudo apt install language-pack-gnome-zh-hans-base -y
cd /tmp/
# Install Microsoft Edge
wget https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_122.0.2365.92-1_amd64.deb?brand=M102 -O ./microsoft-edge-stable.deb
sudo apt install --fix-missing ./microsoft-edge-stable.deb -y
# Install the input method framework `ibus` and the input method editor `ibus-libpinyin`
sudo apt-get install fonts-noto-cjk fonts-noto-color-emoji dbus-x11 zenity -y
sudo apt-get install ibus-libpinyin -y
sh -c 'echo "export GTK_IM_MODULE=ibus" >> ~/.bashrc'
sh -c 'echo "export XMODIFIERS=@im=ibus" >> ~/.bashrc'
sh -c 'echo "export QT_IM_MODULE=ibus" >> ~/.bashrc'
source ~/.bashrc
ibus-daemon -dxr
# Add Input Method `中文 -> 智能拼音`
ibus-setup
# Restart WSL by executing `wsl --shutdown` in Windows PowerShell 5.1 or PowerShell 7.
# Open a new Ubuntu WSL Shell.
ibus-daemon -dxr
microsoft-edge
sudo apt install gnome-text-editor -y
ibus-daemon -dxr
gnome-text-editor ~/.bashrc
Description
gnome-startup-applicationsin Ubuntu WSL affects the use ofibus.ibus-daemonif they need to use IMEs such as ibus under WSLg. Assuming there is a freshly installed Ubuntu WSL 22.04 instance, to useibusinmicrosoft-edge, the steps look like the following.microsoft-edgerunning under WSLg.ibusrequires anibus-daemonprocess to be started in the background. Executeibus-daemon -dxrto ensure that a globally uniqueibus-daemonprocess is started and runs in the background. But the problem is that before opening any application under WSLg, you need to ensure thatibus-daemon -dxrhas been executed once in the Ubuntu WSL Shell.wsl --shutdownin PowerShell 7, then open a new Ubuntu WSL Shell and executeibus-setuponce. At this time,ibus-setupwill prompt you thatibus-daemonis not started at all.ibus, it is often necessary to perform two steps. Take gnome-text-editor as an example.gnome-startup-applicationsto executeibus-daemon -dxrbefore starting the desktop. And Ubuntu 22.04 Desktop does not need to do this at all, because under the Gnome desktop,ibusis out of the box. Refer to https://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login .gnome-startup-applicationsis useful because there is no Gnome standard desktop environment at all. I think the current Ubuntu WSL lacks a mechanism to automatically execute a command likeibus-daemon -dxrin the background when the WSL distribution is running. I can confirm that executingecho "ibus-daemon -drx > /dev/null 2>&1" >> /etc/profile.d/ibus.shto writeibus-daemon -drxto/etc/profile.d/ibus.shhas little to no effect for Ubuntu WSL.Need and use case
ibus-daemoncan always be automatically started when WSL is running.ibus-daemon, which can directly register the relatedibus-daemoncommand as a systemd service throughsystemctl start ibus@$DISPLAY.service. Arch Linux also provides an AUR package namedibus-autostart, which can automatically start the relatedibus-daemoncommand in scenarios such as bootup/shutdown, user login/logout, device plug in/unplug, time events, filesystem events, shell login/logout, Xorg startup, desktop environment startup, and window manager startup. Refer to https://wiki.archlinux.org/title/Autostarting .Additional information
ibusas IME viaim-config#450 , Is it possible to set the IME via im-config instead of environment variables? WhitewaterFoundry/pengwin-setup#385 and Installing gnome-text-editor via WSL, can't bring up the input bar of ibus gnome-text-editor#9 .