On 26.07.2022 02:01, Marc Chamberlin wrote: ...
#!/bin/bash
XA=$(ls -t /run/user/1000/xauth_*|head -1) exec /usr/bin/x11vnc -display :0 -auth $XA -forever -loop -noxdamage -repeat -rfbauth /etc/vncpasswd -o /var/log/x11vnc.log -rfbport 5900 -noipv6 -shared
This isn't a generic solution by any means,
This script can only be run successfully after you have already logged in, which means making this script global system-wide service is useless - just start x11vnc as part of user session (as systemd user service or simply as startup script in your DE). It will get the correct $DISPLAY, $XAUTHORITY etc automatically. There is absolutely no need to run x11vnc as root and it will terminate anyway as soon as X server is stopped (if you log out). But if you insist on over-complicating it ...