#!/bin/bash
#x11vnc -nap -wait 50 -noxdamage -passwd PASSWORD -display :0 -forever -o ~/x11vnc.log -bg

if [ -x /usr/bin/x11vnc ]
then
 if [ -e ~/.config/x11vncpasswd ]
 then
  echo "Tout est OK, on le lance le serveur"
  x11vnc -nap -wait 50 -noxdamage -rfbauth ~/.config/x11vncpasswd -display $DISPLAY -forever -o ~/x11vnc.log -bg
 else
  echo "pas de fichier de mot de passe, on le cré"
  x11vnc -storepasswd ~/.config/x11vncpasswd
 fi
else
 echo "x11vnc n'est pas installé, on l'install"
 sudo apt-get -y install x11vnc
 $0
fi

if [ -e ~/.config/autostart/vncsrv.desktop ]
then
 echo "le lancement automatique est déja activé"
else
 if [ -d ~/.config/autostart ]
 then
  echo "tout est bon"
 else
 echo "le répertoire de démarrage auto n'est pas créé"
  mkdir ~/.config/autostart
 fi
 wget -P ~/.config/autostart/ http://perso.iut-nimes.fr/lbarraille/divers/vnc/vncsrv.desktop
fi

#echo /etc/lightdm/lightdm.conf
#echo [SeatDefaults]
#echo autologin-user=lbarrail
#echo mkdir ~/.config/autostart



