Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. [twilightcat@silent ~]$ cat /usr/local/bin/x11vnc-wrapper
  2. #!/bin/bash
  3. adisplay=$1
  4. xmcookie=/run/lightdm/root/:$1
  5. username=$(who | grep "(:$adisplay)" | awk '{print $1}')
  6. if [ ! -f $xmcookie ] & [ ! -z "$username" ]; then xmcookie=/home/$username/.Xauthority;
  7. else if [ ! -f $xmcookie ] & [ -z "$username" ]; then xmcookie=/var/lib/lightdm/.Xauthority; fi;
  8. fi
  9. /usr/bin/x11vnc -display WAIT:$adisplay -auth $xmcookie -forever -shared -rfbauth /etc/x11vnc.passwd -autoport 5900 -repeat -o /var/log/x11vnc-display-$adisplay.log
  10. exit $?
  11.  
  12.  
  13.  
  14.  
  15. [twilightcat@silent ~]$ cat /usr/local/bin/x11vnc-light-locker
  16. #!/bin/bash
  17.  
  18. while inotifywait -qq -e modify /sys/class/tty/tty0/active; do
  19. CURRENTDISPLAY=$(ps -fC Xorg | grep vt$(sed 's/tty//g' /sys/class/tty/tty0/active) | sed -e 's/\(^\)\(.*\)\/run\/lightdm\/root\/\:\s*\(.*\)/\1\3/; s/ .*//')
  20. /bin/systemctl stop x11vnc@*
  21. if [[ $CURRENTDISPLAY ]]; then
  22. /bin/systemctl start x11vnc@$CURRENTDISPLAY
  23. fi
  24. done
  25.  
  26.  
  27.  
  28.  
  29. [twilightcat@silent ~]$ cat /etc/systemd/system/x11vnc@.service
  30. [Unit]
  31. Description=VNC Server for X11
  32. Requires=graphical.target
  33. After=graphical.target
  34.  
  35. [Service]
  36. Environment=FD_XDM=1
  37. Type=simple
  38. ExecStart=/usr/local/bin/x11vnc-wrapper %i
  39. SuccessExitStatus=2
  40. Restart=always
  41.  
  42. [Install]
  43. WantedBy=graphical.target
  44.  
  45.  
  46.  
  47.  
  48. [twilightcat@silent ~]$ cat /etc/systemd/system/x11vnc-light-locker.service
  49. [Unit]
  50. Description=X11VNC displays autodetect for light-locker
  51. Requires=graphical.target
  52. After=graphical.target
  53.  
  54. [Service]
  55. Type=simple
  56. ExecStart=/usr/local/bin/x11vnc-light-locker
  57. Restart=always
  58.  
  59. [Install]
  60. WantedBy=graphical.target
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement