Hello,
I have been messing around with trying to get remote desktop to work with Hyprland.
This is just a post for me to talk about my experience, how I have done it. And to discuss better ways to go about it.
Problems I Have Faced
Wayland
Wayland is still missing alot of features compared to x11, and remote desktop protocol support is one of them. There are not many tools out there.
Hyprland
Hyprland is a bit qwerky, with a remote desktop session often you can also run things in headless modes. Where the output is not actually done at the physical device. This is for doing things remotely or only with a CLI.
This is really usefull if you are only ever gonna access the machine with a remote desktop.
However, Hyprland a while back doesnt really care about the headless mode, so it no longer works from what I have read on github.
You can still have headless outputs, but Hyprland will not start if theres no valid output. eg on an ssh session.
Remote startup
Now, how should I be able to start a user session remotely with Hyprland, there is no good way I belive.
How I am doing things
Software
- Sunshine: A project for remote desktop access. It has wayland support, and works pretty well. Since its meant for the moonlight, a game streaming solution, the performance is quite high. And theres also the benefits of full device capture and audio working out of the box. Since it creates virtual devices on the host and passes client events though. This works really well especially for games which struggle with absolute mouse positioning.
- Moonlight client: This is for the clients to connect to the host machine.
- OpenVPN/WireGuard: A VPN tunnel to have access to the host machine. (I find this the easiest method to have safe access to the host machine.
Startup
I am still working on this, but the method I have found that works well, is to make an autologin service for tty6 for example, so that from ssh you can switch the session to tty6 remotely, and have it auto start the hyprland session. From there it will set an env variable, and withing the .bash_profile, it will execute Hyprland with a specific Hyprland config for remote desktop purposes. Eg: disabeling physical screens/devices. executing different things at start up etc. Creating Headless monitors.
There is a bug which I still have to make a report for. Hyprland will not exec anything/create any clients for some reason when a monitor isnt really there. Eg: If you disable all physical monitors, and then create a headless one with
exec-once=hyprctl output create headlessit will successfully create the headless monitor, however it will not fully start Hyprland. The only way I have found a way around it is in ssh to create and delete a new headless output withhyprctl --instance 0
Inside of the remote hyprland config, also execute sunshine, preferebly with a delay.
configuring sunshine
Sunshine has a web based configuration and authenticator. Which is on localhost by default. If you are using a vpn, you can access this remotely aswell. You can probably also change this to be exposed aswell if you need to.
Tip: If you really need to see whats going on on your desktop,
wayvncfor the host is really usefull to see what is happening. and connect to it with thetigervncclient. You can start wayvnc withhyprctl --instance 0 dispatch exec 'wayvnc 0.0.0.0 -o HEADLESS-1 --gpu -f 60 -R'
Warning: Make sure to give permissions to all the right applications for hyprland. or disable the permission system if you dont care.
AutoLogin stuff:
/etc/systemd/system/[email protected]/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin <USERNAME HERE> %I $TERM
Environment=AUTOSTART_HYPR=1
~/.bash_profile (will be ran when you sudo chvt 6 from ssh)
if [[ "$AUTOSTART_HYPR" == "1" ]]; then
[[ -f ~/.local/bin/wrappedhl_remote ]] && ~/.local/bin/wrappedhl_remote
else
[[ -f ~/.bashrc ]] && . ~/.bashrc
fi
~/.local/bin/wrappedhl_remote (The exports is for me, do what you want)
#!/bin/sh
cd ~
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export SDL_IM_MODULE=fcitx
export GLFW_IM_MODULE=fcitx
exec Hyprland --config ~/.config/hypr/hyprlandRemote.conf
Downsides
The current issues I’m facing is for one that any new session spawned off of hyprland currently also launch Hyprland :P
For example launching tmux creates a new imbedded Hyprland Session.
This still requires manual steps for initial startup. So if you restart you pc, you will have to ssh into the machine. chvt to 6, and then create & destroy a headless monitor.
Conclusion
It works pretty well when you get things going. The gaming performance is pretty nice, Audio works, and you can probably do the same thing with a gamescope only session.
You can experiment with something like this in the bash_profile:
STEAM_MULTIPLE_XWAYLANDS=1 gamescope -W 1280 -H 720 -r 60 -e --xwayland-count 2 -- steam -gamepadui -steamdeckI dont remember how I streamed it ngl.
Again, I made this post also to discuss any better ways to do this than what I have done. So feel free to comment on anything or ask questions.