Remote desktop on LinuxCNC

In general, this looks like a good idea. Especially for debugging sessions. Because not always convenient to sit next to machine for hours. Instead, will be good to sit in a more comfortable place and tweak/debug it remotely.

Yes, you might be in trouble if something goes wrong and you’ll be unable to switch it off instantly. Therefore, I’m not insist, I’m just sharing an idea and leaves the final decision to you.

VNC server on LinuxCNC

You can use xrdp. This is a good remote desktop. Configuration is pretty simple. But I found two big cons:

  1. unable to connect from MacOS, only Windows (most probably problem in me, but anyway).
  2. No way to connect to the existing X-session. E.g. unable to share the existing desktop like Anydesk/TeamViewer etc.

Therefore, next candidate: x11vnc. This is a VNC server which can share the existing X-session according to Internet. Unfortunately, for me, it doesn’t work at all. More precise, I can’t make it works within reasonable time.

Next! tigervncserver which I found marvellous. It works almost out of the box. Main problem: there is no latest package version on Debian 12 with x0vncserver binary. There is only 1.12 in apt while 1.15 mentioned on GitHub. As a result - no way to get access to the existing X-session. Let’s fix lt!

There are compiled packages for different Unix distributions. While we need something for Debian 12 the Ubuntu 22.04 is the closest one.

After downloading the package from the official source and install attempt

sudo dpkg -i tigervncserver_1.15.0-1ubuntu1_amd64.deb

we have a problem: libjpeg8 needed. But there is a nuance, it should be at least version 8c. However, Debian 12 has only 8b. Therefore, need to download and install it manually:

wget https://archive.debian.org/debian/pool/main/libj/libjpeg8/libjpeg8_8b-1_amd64.deb
sudo dpkg -i libjpeg8_8b-1_amd64.deb

Then we can install tigervncserver with skip dependencies check:

sudo dpkg --force-depends -i tigervncserver_1.15.0-1ubuntu1_amd64.deb

This action leads to another problem: broken packages. Each run of apt says about dependencies problem. To fix this we can go to sudo vim /var/lib/dpkg/status, find Package: tigervncserver and in the list of Depends: replace libjpeg8 (>= 8c) with libjpeg8 (>= 8b).

This is hacky but works.

For the remain VNC configuration Arch Wiki provide all needed information.

Finally, to connect to the local desktop of the existing user we can create corresponding systemd service:

vim ~/.config/systemd/user/x0vncserver.service

And fill it with:

[Unit]
Description=Remote desktop service (VNC)

[Service]
Type=simple
ExecStartPre=/bin/sh -c 'while ! pgrep -U "$USER" xfce; do sleep 2; done'
ExecStart=/usr/bin/x0vncserver -rfbauth %h/.vnc/passwd

[Install]
WantedBy=default.target

Just replace "$USER" with your user or pass env variable. Then start the service:

systemctl --user daemon-reload
systemctl --user enable x0vncserver.service
systemctl --user start x0vncserver.service

Done. Now you can physically log into LinuxCNC with graphical interface and then connect to the same desktop remotely.