Opticos / GWSL-Source

The actual code for GWSL. And some prebuilt releases.
https://opticos.github.io/gwsl/
Other
1.15k stars 79 forks source link

Not working with WSLg plus Ubuntu on Windows Community Preview #61

Closed UGatgithub closed 3 years ago

UGatgithub commented 3 years ago

Nice tool, tested and works with Ubuntu 20.04 LTS but not once you install and run WSLg in combination with the actual Ubuntu on Windows Community Preview.

I expect for that it’s now needed that you implement what was stated here:

What will happen when WSL2 gets official Wayland support? I am just as excited about this as you are. Till it is available, GWSL will only function as an XServer. When Wayland is available, there will be an option to swicth between Wayland and X as a GWSL backend. The shortcut creator and app launcher will continue to work in the new Wayland mode.

Beside the Ubuntu Preview I installed Debian and Ubuntu 20.04 under WSL2 and all 3 distros are discovered by your tool and work when I start already working GUI Apps via Windows Start menu (new option in the preview). In your Linux Apps Menu they show up but don’t open when clicking them.

Pololot64 commented 3 years ago

(Got it and will respond but afk for a while)

Pololot64 commented 3 years ago

First of all, I wrote the explanation in the website long before we knew what WSLg would be like. Now that is is almost out I am still deciding how to integrate them if it is still necessary

I do not know what is causing the conflict between both servers but I assume that there are multiple issues combined together. I cannot test for certain because I am unable to get the insider preview.

Is GWSL exporting the display for itself or did you remove the export code from .profile etc?

Also, it may make a difference if you try using the GWSL 1.3.8 beta. Sorry for my "all over the place" answer. I simply do not much information to work with and respond to :(

UGatgithub commented 3 years ago

I did not change any setup just installed and it worked fine with wsl2 but not with wsl2+wslg. I am awk now so I can‘t check the version, but maybe it helps that I downloaded from Microsoft Store.

Pololot64 commented 3 years ago

It shouldn't matter whether it is the store version or not but feel free to post when available if you want to follow up with the issue. :)

Also, if you want you can sign up for the Store 1.3.8 beta which fixes many issues here: https://forms.office.com/r/CwwSkC9Arp

Andrew-J-Larson commented 3 years ago

I would imagine that WSLg is likely setting its own display:

We preconfigure the user distro environment variables DISPLAY, WAYLAND_DISPLAY and PULSE_SERVER to refer these servers by default so WSLg lights up out of the box.

From https://github.com/microsoft/wslg#wslg-system-distro

Pololot64 commented 3 years ago

You'd think the a .profile environment variable would override but idk.

Andrew-J-Larson commented 3 years ago

You'd think the a .profile environment variable would override but idk.

I mean, I know using a .bashrc or any .[SHELL]rc file equivalent usually sets display for me, but I mean does .profile do that too?

Andrew-J-Larson commented 3 years ago

If what I'm reading is correct though, the directory %userprofile%\.wslconfig (e.g. C:\Users\Pololot64\.wslconfig) is likely what is overriding any distro set environment variables.

Pololot64 commented 3 years ago

Hmm. The app launcher and shortcut creator set the variable per app so it should override there. Putting it in .profile should override as soon as you start a bash session

Andrew-J-Larson commented 3 years ago

Hmm. The app launcher and shortcut creator set the variable per app so it should override there. Putting it in .profile should override as soon as you start a bash session

Well at least the source code is there, so maybe they are doing something funky as soon as a GUI application is detected and started.

Pololot64 commented 3 years ago

Hmm. Well I am closing this for now because it is not even out yet. Much can change

Andrew-J-Larson commented 3 years ago

I also found constexpr auto c_wslgconfigFile = "/mnt/c/ProgramData/Microsoft/WSL/.wslgconfig";, on line 27 in https://github.com/microsoft/wslg/blob/main/WSLGd/main.cpp

Pololot64 commented 3 years ago

🤷‍♀️

Andrew-J-Larson commented 3 years ago

I think I know where part of the culprit is though, towards the end of https://github.com/microsoft/wslg/blob/main/WSLGd/main.cpp there are some monitors with LaunchProcess, so I assume it's likely around there where the weirdness with DISPLAY being overridden is likely happening.

Pololot64 commented 3 years ago

I looked but I don't think it is related. It seems to handle the rdp connection on the windows side but tbh I do not read cpp very well. Also Idk if it is really a "bug" and if it even needs fixing. I was planning compatability with it but that was before anyone knew what it was

Andrew-J-Larson commented 3 years ago

Or I might just be stupid, and it's just https://github.com/microsoft/wslg/blob/main/WSLGd/main.cpp#L187

where it initializes the following:

        {"HOME", passwordEntry->pw_dir},
        {"USER", passwordEntry->pw_name},
        {"LOGNAME", passwordEntry->pw_name},
        {"SHELL", passwordEntry->pw_shell},
        {"PATH", "/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"},
        {"XDG_RUNTIME_DIR", c_xdgRuntimeDir},
        {"WAYLAND_DISPLAY", "wayland-0"},
        {"DISPLAY", ":0"},
        {"XCURSOR_PATH", "/usr/share/icons"},
        {"XCURSOR_THEME", "whiteglass"},
        {"XCURSOR_SIZE", "16"},
        {"PULSE_AUDIO_RDP_SINK", SHARE_PATH "/PulseAudioRDPSink"},
        {"PULSE_AUDIO_RDP_SOURCE", SHARE_PATH "/PulseAudioRDPSource"},
        {"USE_VSOCK", socketFdString.c_str()},
        {"WSL2_DEFAULT_APP_ICON", "/usr/share/icons/wsl/linux.png"},
        {"WSL2_DEFAULT_APP_OVERLAY_ICON", "/usr/share/icons/wsl/linux.png"},
        {"WESTON_DISABLE_ABSTRACT_FD", "1"}
Andrew-J-Larson commented 3 years ago

I looked but I don't think it is related. It seems to handle the rdp connection on the windows side but tbh I do not read cpp very well. Also Idk if it is really a "bug" and if it even needs fixing. I was planning compatability with it but that was before anyone knew what it was

Yeah, well, at least for doing the switching, you know about the .wslconfig now. So that should help in doing the GUI switching.

Pololot64 commented 3 years ago

maybe

Pololot64 commented 3 years ago

afk for now though