0

Currently, I am starting x11vnc on my Pi 400 (stock Raspbian) after it boots up (with no display attached) via ssh with command x11vnc -forever -display :0

How can I do it with systemd? I am trying this file:

[Unit]
Description=x11vnc
After=graphical.target

[Service] Type=idle ExecStart=/usr/bin/x11vnc -forever -display :0 > /home/pi/x11vnc.log

[Install] WantedBy=graphical.target

but that does not seem to work? Any ideas why? I am quite new to systemd.

sup
  • 135
  • 5
  • 1
    Why not just use the provided VNC server and the normal desktop? Just set the default resolution and start up mode to GUI (needing sign-on) in raspi-config and then connect to the VNC server from your client... –  Nov 22 '20 at 15:46
  • 1
    Welcome. Please edit in the output from systemctl status whateverthatserviceiscalled. – goldilocks Nov 22 '20 at 15:55
  • goldilocks : with the accepted answer below, it works already.

    Andyroo : If I understand it correctly, it would start a new X dispaly. I want to see the same display as I use through VNC once and when I turn on my projector. But I did not specifu that in the question.

    – sup Nov 22 '20 at 18:50
  • No wonder I was baffled :-) No problems. –  Nov 22 '20 at 20:22

1 Answers1

2

Try this Unit:

[Unit]
Description=x11vnc
After=graphical.target

[Service] User=pi WorkingDirectory=/home/pi Environment=DISPLAY=:0 ExecStart=/usr/bin/x11vnc -forever

[Install] WantedBy=graphical.target

Don't forget to enable the service:

rpi ~$ sudo systemctl enable yourx11vnc.service

The logged messages you will find in the journal with journalctl -b -e.

Ingo
  • 42,107
  • 20
  • 85
  • 197
  • Perfect answer, thank you. Especially for the journal bit. Though I get a message seemingly written in 2006 about using -ncache. But it warks flawlessly. – sup Nov 22 '20 at 18:49