Skip to content

Instantly share code, notes, and snippets.

@mjtiempo
Created November 24, 2022 02:42
Show Gist options
  • Save mjtiempo/8662e88da74236c58115bed5cc78ceaf to your computer and use it in GitHub Desktop.
Save mjtiempo/8662e88da74236c58115bed5cc78ceaf to your computer and use it in GitHub Desktop.
TigerVNC systemd service using sddm on kde plasma
[Unit]
Description=Remote desktop service (VNC) for :0 display
Requires=display-manager.service
After=network-online.target
After=display-manager.service
[Service]
Type=simple
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment XAUTHORITY=$(find /var/run/sddm/ -type f)"
Environment=HOME=/root
ExecStart=x0vncserver -display :0 -rfbauth /root/.vnc/passwd
Restart=on-failure
RestartSec=500ms
[Install]
WantedBy=multi-user.target
@erwin
Copy link

erwin commented May 11, 2023

I think that @toneoesa made a typo... It is the -fg switch for foreground mode that seems to be required.

ExecStart=x0vncserver -fg -display :0 -rfbauth /root/.vnc/passwd

If you want to connect from another system, you probably also want to add localhost -no:

ExecStart=x0vncserver -fg -display :0 -localhost no -rfbauth /root/.vnc/passwd

@Natetronn
Copy link

Natetronn commented Jul 4, 2023

May require a bit of sleep to get the service to start on some systems:

ExecStart=/usr/bin/bash -c '/usr/bin/sleep 3 && /usr/bin/x0vncserver -display :0 -rfbport 5904 -passwordfile /root/.vnc/passwd &'

Might be able to add it to ExecStartPre instead, but I haven't tested:

ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment XAUTHORITY=$(find /var/run/sddm/ -type f) && sleep 3"

Or on its own ExecStartPre, after the first one; also untested:
ExecStartPre=/usr/bin/bash -c "/usr/bin/sleep 3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment