Monday 11 February 2019

XWindows on WSL

I generally use linux headless as the functions I need can be initiated and controlled from the command line.  It occured to me that there are potentially some GUI functions which would be useful and my initial reaction is to have an RPI build with a desktop.
However the idea is very uninspiring and it then occured to me that using Xwindows software on Windows I could get GUI sessions without an  RPI desktop.
Xming provides a simple popular solution which works as expected.
Mobaxterm also provides an Xserver which is integrated into its other functions.

Clearly an Xwindows server is not much use without software.  As my RPIs dont have desktop programs installed I cant do much with them by default.

It occured to me that WSL (Windows Sub-system for Linux) would be much better as a source for client applications at least for playing/testing.  WSL doesn't include a GUI so Xming Xserver can be used on Windows show windows, the server should be started automatically at startup or before using any sessions.    
To get a terminal window you can use Putty.  Simply create a new putty session and in Connection>SSH>X11 tick "enable X11 forwarding" and specify "X display location" as localhost 0:0.  The connection userid and password are john/secret. 

WSL doesn't have any GUI software either so we have to install some for testing. I found this article very helpful.  I can get some sample GUI programs by installing x11-apps.  Before I did that I had to do an apt update/upgrade on Windows and this took a couple of attempts and quite a lot of CPU time for installation.
Once x11-apps is installed I can add "export DISPLAY=:0" at the end of .bashrc.
xeyes is a nice first program and xclock is useful.
I then installed a terminal window (xterm) and editor (gedit), both of which required significant further software additions to WSL.

I now have a basic useful Xwindows system to use a basis for understanding better how it works.

As I run RPIs headless I dont have x-windows installed  cant run x-windows based programs.  However as I now have x-windows on Windows-10 and x-windows is famous for being able to run windows on remote machines.
1) On Windows-10 WSL install x-utilities: apt-get install x11-xserver-utils
2) On Windows-10 WSL permit RPI to start sessions:  xhost +
3) On RPI install some x-windows apps: apt-get install x11-apps xterm
4) On RPI command line send remote display: export DISPLAY=192.168.0.5:0
5) On RPI command line run x-app: xeyes &
6) App now runs and displays a window on Windows-10
I tested this successfully with paprefs, which is one of the programs I have "missed"
This article maybe useful





No comments:

Post a Comment