-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
- Lack of an application similar to
gnome-startup-applicationsin Ubuntu WSL affects the use ofibus. - In the current state, users often need to manually start
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.
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- At this point, I can indeed use ibus to input Chinese in
microsoft-edgerunning under WSLg. 
- There is a very cumbersome thing here. Using
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. - The easiest way to verify is to restart WSL by executing
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. 
- This means that when running GUI software using
ibus, it is often necessary to perform two steps. Take gnome-text-editor as an example.
sudo apt install gnome-text-editor -y
ibus-daemon -dxr
gnome-text-editor ~/.bashrc
- In the standard Ubuntu 22.04 Desktop environment, there is a complete Gnome desktop, so you can use
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 . - For Ubuntu WSL, I don't think
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
- Provide a document to guide the implementation of the so-called automatic startup mechanism in Ubuntu WSL. Of course, the better option is to provide a kind of apt-get application so that
ibus-daemoncan always be automatically started when WSL is running. - Taking Arch Linux's https://wiki.archlinux.org/title/IBus document as an example, Arch Linux provides an AUR package named
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 . - It would be nice if Ubuntu WSL provided some similar apt-get app.
Additional information
- This is the result of further investigation into Unable to switch to
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 .
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request