Friday, October 26, 2018

VNC server for Cinnamon with systemd

This is what I did to enable a VNC server on CentOS 7.5, with the Cinnamon desktop. (The desktop is configured to automatically login at boot.)

yum install x11vnc
# or on Debian-based systems:
# apt install x11vnc

Create the file /etc/systemd/system/x11vnc.service :

[Unit]Description=VNC Server for X11
Requires=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -display :0 -rfbauth /etc/x11vnc.pwd -shared -forever -o /var/log/x11vnc.log
ExecStop=/usr/bin/x11vnc -R stop
Restart=on-failure
RestartSec=2

Set the VNC password (replace MY_PASSWORD)

x11vnc -storepasswd MY_PASSWORD /etc/x11vnc.pwd

Finally:

systemctl daemon-reload
systemctl enable x11vnc
systemctl start x11vnc

There are many other x11vnc options that may be useful in some circumstances (see man x11vnc). For example :
-noxdamage
-loop
-ncache