INGREDIENTS
- Windows 10 October 2018 Update (1809)
- Ubuntu 18.04 / WSL1 @ Microsoft Store
- Xfce Desktop Environment v4
X410 supports Windowed Apps mode and it can be used to seamlessly intermix apps from Windows and Windows Subsystem for Linux (WSL). The following demonstrates a way to simplify managing Linux GUI apps and various UI settings with a minimal set of Xfce4 components.
PREPARATION
We'll be using Ubuntu 18.04 from Microsoft Store but you should also be able to achieve a similar result with any WSL distribution by following the steps described below.
After installing Ubuntu 18.04, execute the following command line first to have the installed Ubuntu binaries and data files up to date.
sudo apt update && sudo apt -y upgrade
STEP 1 Install Xfce4
There are numerous Linux GUI desktop environments, however, we're using Xfce4 for this article as it works well with WSL and its components can be individually launched.
Execute the following command to install Xfce4 desktop environment and its default terminal emulator.
sudo apt install xfce4 xfce4-terminal
When you install Xfce4 package, it also installs Xfce4 related components that are ineffective or causing unexpected behavior for WSL. You should simply remove the following packages:
- Power Manager (xfce4-power-manager)
- Screensavers and lockers (xscreensaver, gnome-screensaver, light-locker)
sudo apt purge xfce4-power-manager xscreensaver gnome-screensaver light-locker
STEP 2 Launch X410 in Windowed Apps mode
X410 can also be launched in Windowed Apps mode using a command-line switch from a Windows Command Prompt.
x410.exe /wm
TEST DRIVING
STEP 3 Set DISPLAY environment variable
In order for Linux GUI apps and modules to render their output on X410, they need to know where X410 can be found. The DISPLAY environment variable is used for that purpose and it should be set to '127.0.0.1:0.0' if you're using default settings in X410. You can also get this information from the tooltip popup for X410 tray icon.
export DISPLAY=127.0.0.1:0.0
STEP 4 Start only core Xfce4 components
Xfce4 is comprised of many modules and when you launch "xfce4-session" or "startxfce4", it automatically loads them as needed. However, for our purpose, we only need two core components:
-
When you first launch this daemon, it loads all the settings you previously configured for Xfce4 (ex. UI themes, mouse pointer size, keyboard layout and etc.). It'll be running in background and when you make changes to the Xfce4 settings, they'll be automatically applied to the all running X-Window apps.
-
We'll be customizing this panel and use it for launching Linux GUI apps.
Execute the following command line to start the core Xfce4 components listed above.
xfsettingsd --sm-client-disable; xfce4-panel --sm-client-disable --disable-wm-check &
STEP 5 Adjust the layout and app shortcuts for Xfce4 panels
When you first launch xfce4-panel, it'll ask you if you want to create default panels. When you answer "Yes", two panels are created; one for listing currently running apps and the other for launching installed apps.
We deleted the first panel and moved the second one to the right side of the Windows desktop. We also made some changes to the shortcut buttons for the panel.
Please note that since we are not using xfce4-session, the "Log Out" menu won't work; you cannot close Xfce4 using a menu from the Xfce4 panel. When you want to terminate Xfce4, you can just shutdown X410 by using its "Exit" menu.
TIPS AND TRICKS
If you're using Tilix and want to set it as a default terminal emulator for Xfce, you need to assign it through [ Preferred Applications ] » "Utilities" » "Terminal Emulator" » "Other". When specifying its file path, don't forget to add the "-e" switch for executing a command that was passed as an argument (ex. htop):
tilix -e "%s"
It seems you cannot launch applications that require root access rights (ex. Synaptic) via the xfce4-panel shortcuts. You can of course launch them in terminal command prompt using the "sudo" command.
CLEANING UP
STEP 6 Create a batch file for launching X410 and Xfce4 components
The following is a Windows batch file that launches X410 and Xfce4 components mentioned in the previous steps.
@echo off
start /B x410.exe /wm
ubuntu1804.exe run "if [ -z $(pidof xfce4-panel) ]; then export DISPLAY=127.0.0.1:0.0; cd ~; xfsettingsd --sm-client-disable; xfce4-panel --sm-client-disable --disable-wm-check; taskkill.exe /IM x410.exe; fi;"
STEP 7 Create a Windows shortcut
You can directly launch the batch file created in Step 5 and have your Linux GUI environment ready. However, you can use the following VBScript and a Windows shortcut to silently launch the batch file and hide it from the Windows Taskbar. Please note that the VBScript file should be in the same folder as the batch file.
If WScript.Arguments.Count <= 0 Then
WScript.Quit
End If
bat = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")) & WScript.Arguments(0) & ".bat"
arg = ""
If WScript.Arguments.Count > 1 Then
arg = WScript.Arguments(1)
End If
CreateObject("WScript.Shell").Run """" & bat & """ """ & arg & """", 0, False
You can then create a shortcut for the batch file created in Step 5 and set its "Target" as the following (The "Start in" option for the shortcut should also be pointing to the folder where the actual files are located):
wscript.exe bat-launcher.vbs xfce4-sidekick
Do you want to automatically launch the script when you log in? Just copy the shortcut to the Windows "Startup" folder!
Your Linux sidekick is now ready for some action!
TIPS AND TRICKS
X410 has DPI scaling options and when you enable one of them, X410 automatically scales Linux GUI apps according to the DPI settings of the monitor that they are displayed on. However, if you want the most crisp and sharp output as possible, you should consider setting the scaling option in X410 to "None" and upscaling the output from the actual Linux GUI apps.
As of this writing, only Qt5 based apps support fractional scaling. For example, if you want to only launch GNU Octave at 150% scaling, you can use the following command:
QT_SCALE_FACTOR=1.5 octave
If you want all Qt5 based apps to be scaled at 150%, you can add the following command to your login script (ex. ~/.bashrc):
export QT_SCALE_FACTOR=1.5
For GDK based apps, only integers are accepted for a scaling factor:
GDK_SCALE=2 gedit
Xfce4 is a GDK based app hence its settings for UI themes only affects GDK apps. If you want to install and change UI themes for Qt5 apps, you should install "qt5ct" package and add the following to your login script (ex. ~/.bashrc):
export QT_QPA_PLATFORMTHEME=qt5ct
When you want to change the UI theme for Qt5 based apps, you can execute the "qt5ct" from the command line or launch "Qt5 Settings" from the xfce4-panel shortcuts.
After changing your login scripts, you need to restart Xfce4; just exit X410 and then re-launch the startup shortcut created in Step 6.
Ubuntu repositories only seem to have the "Arc" GTK theme (arc-theme). If you're interested in using the "Adapta" GTK theme, you can use the following commands:
sudo add-apt-repository -y ppa:tista/adapta && sudo apt update && sudo apt install adapta-gtk-theme