Ylianst/MeshAgent

Linux Wayland support

Opened this issue Β· 41 comments

More and more Linux distro's are moving towards Wayland for various reasons. I have moved due to better performance for certain applications. I hope at some point MeshAgent can support remote desktop sessions with Wayland.

I believe this feature request is better here in MeshAgent than Ylianst/MeshCentral#2719 as it's an Agent issue.

I'm still looking into seeing how we can support remote desktop for Wayland. From what I have seen thus far, the security primitives of Wayland don't expose an API to be able to scrape the UI. There appears to be a plug-in or sorts, but is specific to the windowing manager that you use, so would be problematic from a support point of view since we try to target as broadly as we can.

A while ago someone had mentioned a package that they saw was used by some other tools. That one looked promising, but it was quite a different use case, as it required the user to explicitly turn on session recording, and then it would be able to capture the current session only.

I'm open to suggestions for packages/API's/etc that could be useful to look at, as I'm by no means a Wayland expert, lol. If you don't see any movement with KVM over Wayland, it's not because I'm ignoring it, I'm still trying to grasp how I can support it.

map7 commented

DWservice works with Wayland screens and I think the agent itself is open source, you just cannot self-host the server. Might be worth checking out.

https://github.com/dwservice/agent

Thanks! I'll take a look over the holidays

DWservice works with Wayland screens and I think the agent itself is open source, you just cannot self-host the server. Might be worth checking out.

https://github.com/dwservice/agent

I've just tried to use DWservice on Wayland, and it seems to be unsupported at least on Fedora 35 (errors out with "XWayland is not supported" - XWayland is not running btw)

I'm not sure if it helps, but Rustdesk appears to work on my PopOS 2022 Wayland desktop. I haven't been able to use MeshCentral for about a year on that machine. https://github.com/rustdesk/rustdesk

Find in the Github readme

Change Wayland to X11 (Xorg)
RustDesk does not support Wayland. Check this to configuring Xorg as the default GNOME session.

So not the solution for Wayland

I'm a +1 on wayland support..

veitw commented

The wayvnc VNC server for Wayland might be an interesting open source to look at how to get Wayland support, too:

https://github.com/any1/wayvnc

gdei commented

OBS Studio is a screen recording software that works with Wayland:

https://github.com/obsproject/obs-studio

any news on this? wayland support is currently the most important missing thing in meshcentral

please note that on my debian sid gnome desktop, wayland version, obs studio is able do grab my screen through pipewire: when I add a source in obs, I have the possibility for Β«Screen Capture (Pipewire)Β» and Β«Window Capture (Pipewire)Β». And it works on my wayland desktop.

On the console from which I started obs. I have these:

info: [pipewire] Available captures:
info: [pipewire] - Desktop capture
info: [pipewire] - Window capture

So pipewire is definitely able to capture desktop and windows in wayland.

And indeed, a brief research on the web shows that wayland screen sharing through pipewire has been available since mid 2018: https://jgrulich.cz/2018/07/04/how-to-enable-and-use-screen-sharing-on-wayland/

It does not include input, but it could show how to do it.

I looked into Pipewire in the past, and found that the use case for pipewire was a bit different than the current use case for how we do desktop remoting. The main one being, that pipewire (at least at the time, it's been a while), requires the user to explicitly start/enable sharing for a particular session. I wasn't sure if that persisted across reboots, and logout/login... But it also didn't seem to work from the login screen. But the main issue, was that at the time, support was required at the distro level, and when I looked into it, installation was a bit cumbersome for some distros...

Someone pointed out that later on vnc added support for Wayland, so at some point I had wanted to peruse the codebase for that to see if it could be adapted to our use case scenario.

It looks like only wlroots-based compositor. I was able to grab framebuffer using KMS drm dumb buffer API on Intel GPU but I am not sure of it will work on GPU or if that API is stable enough. Let see if I can spend time during Christmas break. I recall I sent PR few years ago.

my desktop is pure gnome (so not wlroots based), and I'm note aware of anything specifically enabled for obs to work. I looked in my settings, and screen sharing is indeed disabled. I just ran obs, and it worked with my wayland session.

Now that I think of it, I do have xdg-desktop-portal-gnome installed, maybe that's how pipewire gets access to the desktop...

For the record, I don't think that it would work for the login screen, but having the possibility to get desktop access after login, even on demand, would be a huge boost compared to what we have now (nothing).

another possibility, less general but probably easier at first, could be to plug into gnome's existing remote desktop capabilities... it's already there, but limited to gnome...

Are you running vanilla gnome? When I looked into it, it said I would have to manually compile gnome to include a patch to add support for pipewire. In addition to gnome tho, we need to support other window managers too, and I remember at the time there was no support for pipewire in some of the other DMs. But that's why I wanted to look at vnc to see if their support was DM specific.

yep, vanilla gnome on debian sid, nothing hand compiled or patched.

I don't know that pipewire permits controlling the desktop, maybe just viewing. I cited it more as a source of documentation: to see how they manage to get access to the desktop content. Same for gnome remote desktop: you can probably plug in it to get easy access to gnome desktops, but you can also have a look at how they manage to get access to and control the desktop, so you can implement your own generic solution.

Any news about Meshcentral being compatible with Wayland ? (Ubuntu 22.04 is in Wayland by default and Wayland seems to be the future)

I'm a newbie about Xorg or Wayland but I understand that there are some security issues with Xorg and I don't want to change this config permanently in computers I help.
Also, I can't help for the code but i'm available to tests if needed :)

πŸ‡«πŸ‡· πŸ‡¬πŸ‡« For french speaker, I wrote a documentation where I simply explained the stakes of the present problem and I presented a workaround (choosing Xorg in Ubuntu 22.04) : https://librairie.grap.coop/books/aide-a-distance/page/installation-sur-ubuntu-2204-wayland-et-xorg

veitw commented

The Wayland devs' preferred method to access the Wayland screen is using the PipeWire screen capture API, but that would require the user to click through a dialogue to select which screen or window to share instead of simply accessing the screen, so this would be more a thing for a Linux version of the Mesh Assistant than for the Mesh Agent.

Just one thing to add to the list of apps that already allow access (both capture and control) to both X11 and Wayland screens is GNOME's built-in remote desktop and screen sharing service:
https://gitlab.gnome.org/GNOME/gnome-remote-desktop

Even if it is not possible to replicate its functionality, maybe one could simply use this service to access the screen at least for desktops with GNOME running, which are at least the most:
gnome-remote-desktop comes with a tool called grdctl which allows to control this service. As GRD can accept both RDP and VNC and allows full configuration of the service for both VNC and RDP; enabling/disabling access, allow/disallow remote control, set/remove password (and username), configure "ask for access" dialogue, ..., so the VNC or RFB capabilities could be used that Mesh Central already offers.
On the downside, this might be slower as the screen data is translated one more time, and this only works when the desktop session is already running but not on the log-in screen.

I ran into this issue on raspberry pi os. I'm working around it by switching to X11 for now, but that won't be an option forever. I think having a partial solution would be better than none. In my case the raspberry is already set to auto-logon, so a user session is there. If mesh could tap just tap into the running session, that would still be better than nothing at all.

Any updates on this?

because of missing wayland support, meshcentral is basically broken for me since 2 years, because I can not access the desktop of my linux machines. :-(

thanks but I'm on wayland, I won't ever go back to X11 ;D

Then sadly until somebody knows C and knows wayland, the won't be support for it
This is a community project after all

Fedora 40 does not support X11. What to do??

@Direnor nothing you can do, unless u can install X11 and switch to it,
wayland isnt supported because we need a C developer who can implement it for us

@Direnor ive just downloaded the Fedora Workstation 40 and set it up in a VM,
if you install plasma-workspace-x11, make the changes to custom.conf from the readme.md
https://github.com/Ylianst/MeshAgent?tab=readme-ov-file#special-note-about-kvm-support-on-linux
then restart, you will then have remote desktop!
its only a work around but at least it works!

my fingers crossed that some unsing hero will be able to implement it :D . On my end it becomes a pita, as more and more of distributions use Wayland by default. If I recall correctly Fedora won't even install x11 session in the next version.
Also some of the apps switched to Wayland as well and work better under it (but in general this is tricky, transitional period - some apps work better under Wayland, some under X11).

RHEL9 is now using Wayland by default, so bumping this again this is going to become more and more of a problem for MeshCentral, and unfortunately a blocker for us to implement due to no Wayland support.

@Coolguy3289 and again bumping the fact that there are no developers of for the meshagent, so unless u know C or know anyone who knows C and can code the wayland. Then sadly the isn't anything we can do!
You should have to re-enable/download/switch to X which is still possible

@krayon007 Any chance you can share what you discovered in your research?

We could apply for a grant with Nlnet, and the more info we have, the better:
Ylianst/MeshCentral#2719 (comment)

I've noticed that Fedora, Ubuntu, etc that have adopted Wayland by default, have been shipping an RDP that seems to work decently well with Wayland (out of the box). Is there any chance this can be taken advantage of with the MeshAgent?

Additionally, could we create a donation bucket specifically tied to paying for the development of solid Wayland support in MeshCentral agents? I'm happy to put my money where my mouth is.

si458 commented

@bmcgonag RDP on linux should already work in meshcentral,
just enable RDP in linux,
check you can RDP from another machine to your linux machine,
then in meshcentral web ui, click the Web-RDP button, login and away you go

si458 commented

@bmcgonag i do have a donation page and im taking donations to help me carry on with the development of meshcentral
https://www.si458.co.uk/2024/01/05/donation/

im a one man band at the moment and about 2 days a week to helping fix bugs etc with meshcentral
but sadly i dont no C/C++ so i cant implement the wayland support

so if you know anybody who does know C/C++ and Linux Desktops then please point them in this direction!

@bmcgonag RDP on linux should already work in meshcentral, just enable RDP in linux, check you can RDP from another machine to your linux machine, then in meshcentral web ui, click the Web-RDP button, login and away you go

doesn't that work only when the mc server is in the same network as the machine it tries to control ?

si458 commented

@hobbes nope πŸ‘
so long as you have the meshagent installed on the machine, and rdp enabled
you can use the web-rdp as it talks to 127.0.0.1:3389 ON the machine itself πŸ‘
OR
you can use the local agent only group which means the meshcentral machine
WOULD need access of some form to your remote machine

so long as you have the meshagent installed on the machine, and rdp enabled
you can use the web-rdp as it talks to 127.0.0.1:3389 ON the machine itself πŸ‘

damn, does not work for me... I'll open a proper issue, this should not pollute here. But if it works, then wayland problem partially solved.

si458 commented

@hobbes sure no worries! open it in the meshcentral repo tho
as i bet its not a meshagent issue but something with meshcentral ui/code instead