How to use Wayback and Waypipe to run IntelliJ remotely
At some point I started to build a Jetbrains plugin for Teamtype formally known as Ethersync, which is a “Peer-to-peer, editor-agnostic collaborative editing of local text files”, because I wanted to give my peers and me the possibility to collaborate remotely in real time, regardless of the individual, favorite coding environment. I'm working at a Java shop and most of my peers use IntelliJ while I'm using Neovim and there was no editor-agnostic collaboration tool available and this circumstance sparked the desire to create Teamtype for Jetbrains Platform, after I stumbled across this presentation of Ethersync.
When I'm working on Open Source projects, such as this Teamtype Jetbrains plugin, I like to use my old, little ThinkPad S1 Yoga from 2013 while I'm lying relaxed on the sofa (at the time of writing this article, I'm often nap trapped, so I want to hack when the baby is asleep). Thanks to Linux, this old machine runs still perfectly fine for most things I do. However, developing a plugin for the Jetbrains platform requires a more powerful machine then my old, little Yoga due to the fact that Jetbrains product are heavy JVM applications and the Yoga has not enough RAM available. My desktop machine is powerful enough but in my free time I like to be on the sofa and not at my desk (being nap trapped makes it impossible too). So, I wanted to have a solution that let's me code, run, and test the Teamtype plugin from my Yoga, anywhere in the local network.
For adjusting the code I already had a simple solution to it. To make code changes to the Teamtype plugin, I can log into my desktop computer from my Yoga via SSH and then I can use Neovim setup with the KotLin Language Server. But running IntelliJ to test the Teamtype plugin, requires a remote graphical desktop environment to my desktop machine. Because I'm on Wayland on my Linux machines, I needed the equivalent of SSH X forwarding to run IntelliJ on my desktop and then to have the window drawn on my Yoga.
Waypipe is the equivalent to SSH X forwarding, which “is a proxy for Wayland clients. It forwards Wayland messages and serializes changes to shared memory buffers over a single socket. This makes application forwarding similar to ssh -X feasible.” Based on this information I installed the waypipe package on both machine and I was hopeful that I can now code, run, and test the Teamtype plugin from the sofa. However, following command failed and didn't give me a remote application window of IntelliJ.
❯ waypipe ssh user@desktop idea
**Start Failed**
Unable to detect graphics environment.
After investigating further, it turns out when you run Java applications on OpenJDK 21, i.e. IntelliJ, the application will run inside of XWayland (a compatible layer for X11 applications) because OpenJDK 21 is not yet compatible with Wayland, and XWayland is not compatible with Waypipe. This issue bothered me for months because the core team of Teamtype had a high development speed, while I was nap trapped and I couldn't adjust the Teamtype plugin to the latest changes of Teamtype.
Luckily, an idea to fix this issue popped into my head, eventually. Out of the sudden I remembered the video about Wayback by Brodie Robertson and this made me wondering if Wayback can deal also with single application windows that are based on X11, such as OpenJDK 21 applications and in this case more specific IntelliJ. The usage documentation looked promising:
# E.g. to launch WindowMaker
❯ wayback-session wmaker
Based on this information, I installed wayback-x11 on the desktop machine and then I tried to get IntelliJ to appear on the display of my Yoga laptop:
❯ waypipe ssh user@desktop wayback-session idea
[INFO] (wayback-session): Wayback X.Org compatibility layer
[INFO] (wayback-session): Version 0.2
[INFO] (wayback-session): Launching with fd 4
00:00:00.057 [INFO] [backend/wayland/backend.c:587] Creating wayland backend
MESA-INTEL: warning: Haswell Vulkan support is incomplete
00:00:01.063 [DEBUG] [backend/wayland/backend.c:351] Remote wayland global: wl_compositor v6
00:00:01.063 [DEBUG] [backend/wayland/backend.c:351] Remote wayland global: wl_shm v2
…
It worked! Then, I placed a small script on the desktop machine
which changed into the development directory of the Teamtype plugin
and then started IntelliJ with the Teamtype plugin via
./gradlew runIde --no-daemon. Now, I can work on the
plugin from my Yoga machine. Awesome.