logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Using-cage-for-a-seamless-RDP-Wayland-desktop.md (2512B)


  1. ---
  2. date: 2019-04-23
  3. layout: post
  4. title: Using Cage for a seamless remote Wayland session
  5. tags: ["wayland", "cage"]
  6. ---
  7. Congratulations to Jente Hidskes on [the first release of
  8. Cage](https://www.hjdskes.nl/blog/cage-01/)! Cage is a Wayland compositor
  9. designed for kiosks - though, as you'll shortly find out, is useful in many
  10. unexpected ways. It launches a single application, in fullscreen, and exits the
  11. compositor when that application exits. This lets you basically add a
  12. DRM+KMS+libinput session to any Wayland-compatible application (or X application
  13. via XWayland) and run it in a tiny wlroots compositor.
  14. I actually was planning on writing something like this at some point (for a
  15. project which still hasn't really come off the ground yet), so I was excited
  16. when Jente [announced it](https://www.hjdskes.nl/blog/cage/) in December. With
  17. the addition of the [RDP backend](https://github.com/swaywm/wlroots/pull/1578)
  18. in wlroots, I thought it would be cool to combine these to make a seamless
  19. remote desktop experience. In short, I installed
  20. [FreeRDP](http://www.freerdp.com/) and Cage on my laptop, and
  21. [sway](https://swaywm.org) on my desktop. On my desktop, I [generated TLS
  22. certificates per the wlroots
  23. docs](https://github.com/swaywm/wlroots/blob/master/docs/env_vars.md#rdp-backend)
  24. and ran sway like so:
  25. ```sh
  26. WLR_RDP_TLS_CERT_PATH=$HOME/tls.crt \
  27. WLR_RDP_TLS_KEY_PATH=$HOME/tls.key \
  28. WLR_BACKENDS=rdp \
  29. sway
  30. ```
  31. Then, on my laptop, I can run this script:
  32. ```sh
  33. #!/bin/sh
  34. if [ $# -eq 0 ]
  35. then
  36. export XDG_RUNTIME_DIR=/tmp
  37. exec cage sway-remote launch
  38. else
  39. sleep 3
  40. exec xfreerdp \
  41. -v homura \
  42. --bpp 32 \
  43. --size 1280x800 \
  44. --rfx
  45. fi
  46. ```
  47. The first branch is taken on the first run, and it starts up cage and asks it to
  48. run this script again. The second branch then starts up xfreerdp and connects to
  49. my desktop (its hostname is `homura`). xfreerdp is then fullscreened and all of
  50. my laptop's input events are directed to it. The result is an experience which
  51. is basically identical to running sway directly on my laptop, except it's
  52. actually running on my desktop and using the remote desktop protocol to send
  53. everything back and forth.
  54. This isn't especially practical, but it is a cool hack. It's definitely not
  55. network transparency like some people want, but I wasn't aiming for that. It's
  56. just a neat thing you can do now that we have an RDP backend for wlroots. And
  57. congrats again to Jente - be sure to give Cage a look and see if you can think
  58. of any other novel use-cases, too!