Lack of an application similar to gnome-startup-applications in Ubuntu WSL affects the use of ibus.
In the current state, users often need to manually start ibus-daemon if they need to use IMEs such as ibus under WSLg. Assuming there is a freshly installed Ubuntu WSL 22.04 instance, to use ibus in microsoft-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/
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-edge` running under WSLg.
- ![image](https://github.com/user-attachments/assets/8cb006bf-dcf2-4595-a65e-f482505f8341)
- There is a very cumbersome thing here. Using `ibus` requires an `ibus-daemon` process to be started in the background. Execute `ibus-daemon -dxr` to ensure that a globally unique `ibus-daemon` process is started and runs in the background. But the problem is that before opening any application under WSLg, you need to ensure that `ibus-daemon -dxr` has been executed once in the Ubuntu WSL Shell.
- The easiest way to verify is to restart WSL by executing `wsl --shutdown` in PowerShell 7, then open a new Ubuntu WSL Shell and execute `ibus-setup` once. At this time, `ibus-setup` will prompt you that `ibus-daemon` is not started at all.
- ![image](https://github.com/user-attachments/assets/e95bf107-4d3b-4f8a-a0b2-7d2b12378cc6)
- This means that when running GUI software using `ibus`, it is often necessary to perform two steps. Take gnome-text-editor as an example.
- In the standard Ubuntu 22.04 Desktop environment, there is a complete Gnome desktop, so you can use `gnome-startup-applications` to execute `ibus-daemon -dxr` before starting the desktop. And Ubuntu 22.04 Desktop does not need to do this at all, because under the Gnome desktop, `ibus` is 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-applications` is 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 like `ibus-daemon -dxr` in the background when the WSL distribution is running. I can confirm that executing `echo "ibus-daemon -drx > /dev/null 2>&1" >> /etc/profile.d/ibus.sh` to write `ibus-daemon -drx` to `/etc/profile.d/ibus.sh` has 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-daemon` can 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 related `ibus-daemon` command as a systemd service through `systemctl start ibus@$DISPLAY.service`. Arch Linux also provides an AUR package named `ibus-autostart`, which can automatically start the related `ibus-daemon` command 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 https://github.com/ubuntu/WSL/issues/450 , https://github.com/WhitewaterFoundry/pengwin-setup/issues/385 and https://github.com/ubuntu/gnome-text-editor/issues/9 .
Description
gnome-startup-applications
in Ubuntu WSL affects the use ofibus
.ibus-daemon
if they need to use IMEs such as ibus under WSLg. Assuming there is a freshly installed Ubuntu WSL 22.04 instance, to useibus
inmicrosoft-edge
, the steps look like the following.Before executing
echo $LANG
, open a new Ubuntu WSL shell. Make sureecho $LANG
outputszh_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 editoribus-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