Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Add WSLg support #4

Merged
merged 15 commits into from
Oct 17, 2021
Merged

Add WSLg support #4

merged 15 commits into from
Oct 17, 2021

Conversation

meyayl
Copy link

@meyayl meyayl commented Oct 15, 2021

Adds additional environment variables required for WLSg and replaces an existing /tmp/.X11-unix directory with a symlink to the .X11-unix socket provided by WSLg, in case it is not already a symlink.

Copy link
Owner

@saltyming saltyming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Since we run this file as root already.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

Note: replacing the unix-daemon socket /tmp/.x11-unix with a symlink to the unix-daemon socket of the wayland xserver running on the host is not a one-fits-all solution. Since the symlink points to the unix-daemon socket of the already running xerver from the wsl host vm, it will prevent the start of an xserver in the distrubtion.

A solution is required before merging this PR into the main branch, as it will break behavior for systems running their own xserver in their distribution (e.g. with xrdp).

Maybee there is a way to leverage the /dev/xdg device to provide hardware acceleration in a xserver running the distribution?

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

Is this necessary? Since we run this file as root already.

It is just an "esotheric solution" that makes no sense on a second though.

Though, I feel this snippet might suffer from race conditions - which is what made me sudo the commands even though not necessary. It is almost as if /mnt/wslg is not immediatly present sometimes.

@saltyming
Copy link
Owner

Note: replacing the unix-daemon socket /tmp/.x11-unix with a symlink to the unix-daemon socket of the wayland xserver running on the host is not a one-fits-all solution. Since the symlink points to the unix-daemon socket of the already running xerver from the wsl host vm, it will prevent the start of an xserver in the distrubtion.

A solution is required before merging this PR into the main branch, as it will break behavior for systems running their own xserver in their distribution (e.g. with xrdp).

Maybee there is a way to leverage the /dev/xdg device to provide hardware acceleration in a xserver running the distribution?

I have no idea other than making an extra variable whether to enable WSLg or not.

@saltyming
Copy link
Owner

Is this necessary? Since we run this file as root already.

It is just an "esotheric solution" that makes no sense on a second though.

Though, I feel this snippet might suffer from race conditions - which is what made me sudo the commands even though not necessary. It is almost as if /mnt/wslg is not immediatly present sometimes.

It's not needed since in such race conditions, the other parts of the file won't work neither.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

I have no idea other than making an extra variable whether to enable WSLg or not.

I can see how this might work if we introducde a new argument to install.sh (smth. like --wlsg) that writes and additional variable to /etc/bash.bashrc and add env_keep for it in /etc/sudoers.d/systemd-namespace. This way the variable would be available during source /usr/sbin/start-systemd-namespace, and would be looped thru to /usr/sbin/enter-systemd-namespace and could be used for a conditional action.

Let my try the idea. Probably something like --use-wslg-x11-socket is more accurate

wdyt?

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

It's not needed since in such race conditions, the other parts of the file won't work neither.

You are right, it was useless in the first place.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

The generall idea works. Though, I added it as "--no-wslg". The default behavior will set the symlink, while not setting it requires the argument.

The only thing left is to figure out how to identify the added line in /etc/bash.bashrc to update it when parameters change and when uinstalling.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

The current commit adds the parameter --no-wslg to install.sh and is able to update /etc/bash.bashrc. uninstall.sh is fixed to remove the additional lines in /etc/bash.bashrc as well.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

I found the another issue: the loop I introduced to check if packages are already installed breaks if the packages are not already installed.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

That one is fixed now as well.

Good that I have tried to build a new image with my packer project and found the issues right away.
I am still in the process of trying how to leverage /dev/dxg with my own distribution.

@meyayl
Copy link
Author

meyayl commented Oct 16, 2021

I am still in the process of trying how to leverage /dev/dxg with my own distribution.

Works out of the box on my xrdp packer project... BUT: it is terribly slow compared to the software render in full screen.

@saltyming
Copy link
Owner

I am still in the process of trying how to leverage /dev/dxg with my own distribution.

Works out of the box on my xrdp packer project... BUT: it is terribly slow compared to the software render in full screen.

I will merge this pr first. Lemme think of that thing too later.

@saltyming saltyming merged commit 28c5210 into saltyming:master Oct 17, 2021
saltyming pushed a commit that referenced this pull request Nov 24, 2021
* add WSLg support
* fix .X11-unix symlink
* fix .X11-unix symlink permission
* add additional WSLg variables to env_keep
* add install.sh parameter --no-wsl
* add install.sh parameter --no-wslg
* only preserve wslg variables if --no-wslg is not used during installation.
* fix package installation
* ensure package install condition does not break

Signed-off-by: Sung Mingi <[email protected]>

Co-authored-by: meyayl <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants