X410 has two server modes, Floating Desktop and Windowed Apps. We already have a post for the Floating Desktop mode that shows how you can enable systemd in WSL2 and run a full Ubuntu GUI desktop with it. In this post, we are focusing on utilizing the Windowed Apps mode that enables you to run Linux GUI apps side by side with Windows apps.

// Start here

Overall process of enabling systemd in WSL2 and setting it up for an Ubuntu GUI environment is the same for both Floating Desktop and Windowed Apps modes; you just need to adjust the last step where you actually launch the main gnome-session executable.

Hence, we recommend first completing the steps for opening a full Ubuntu GUI desktop on X410 in its Floating Desktop mode as shown in the following post.

Enable systemd in WSL2 and have the best Ubuntu GUI desktop experience!
DONE

Execute the following command and terminate WSL2 completely.

wsl.exe --shutdown



DONE

// Hello Windowed Apps mode

If X410 is not already in Windowed Apps mode, you need to change its Server Mode and restart X410.

DONE

As WSL was shut down in Step 2, you need to open a new WSL console for the Ubuntu distro that was set up for Floating Desktop mode in Step 1.

When you open a new WSL console in this step, you should be in the same environment as the Step 12 for Floating Desktop mode where you just had restarted WSL2 and did not yet execute any command.

DONE

Just like the Step 12 for the Floating Desktop mode, you first need to execute the following command and merge the environment variables for Ubuntu desktop. You can reuse the same script file that was created for the Floating Desktop mode.

. ~/.bash_ubuntu_desktop



You can now execute the following command and have gnome-session ready for your Linux GUI apps running via X410 in its Windowed Apps mode.

gnome-session --systemd-service --session=ubuntu &





When you start Linux GUI apps such as Nautilus, GNOME Terminal etc., you should be able to notice that their UI controls, colors etc. are now more consistent and follow the theme settings for your Ubuntu desktop even though they are running side by side with Windows apps.

Please note that those newly added environment variables are not carried over to a new WSL console. Hence, you should add the merging command to one of your login scripts such as .profile or .bashrc and have those environment variables automatically added whenever you open a new WSL console.

Please also note that you don't have to execute gnome-session every time you open a new WSL console; you just need to have one instance of it constantly running in the background. Even if you execute it multiple times, gnome-session automatically terminates itself if it finds another instance is already running. Anyhow, you can add the following code snippet to your login script for launching gnome-session; unlike starting it directly from an interactive Bash shell as shown above, you don't need to append an & (ampersand) and explicitly push it to the background.

if [ -z "$(pidof gnome-session-binary)" ]; then
    gnome-session --systemd-service --session=ubuntu
fi



When you add all those settings necessary for running Linux GUI apps in Windowed Apps mode to ~/.profile login script, it would be something like the following. Once you have your ~/.profile updated and restarted WSL, you are ready to run Linux GUI apps in Ubuntu desktop theme (colors, icons etc.) without any further configuration after opening a new WSL console.

~/.profile
...
...

# Set DISPLAY environment variable
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0

# Merge environment variables for Ubuntu desktop
if [ -f ~/.bash_ubuntu_desktop ]; then
    . ~/.bash_ubuntu_desktop
fi

# Start 'gnome-session' if necessary
if [ -z "$(pidof gnome-session-binary)" ]; then
    gnome-session --systemd-service --session=ubuntu
fi




DONE

Share This Story, Choose Your Platform!