Teamviewer startup script

When running Teamviewer on Linux my problem was that when in a remote session I would accidentaly close teamviewer on the remote machine I would never be able to reconnect again because it was no longer running. Also after a reboot it doesn't start automatically so I needed a solution that would also start Teamviewer after booting.

Therefor what I did on an open SUSE Linux 11.4 machine is the following:

I have created this script that runs continously and checks if Teamviewer is still running. If not I restart the process. What I have also added is that the screensaver is activated so that no users on the local machine can access the desktop. This script is then activated at login, for that purpose I have configured the system to automatically login a user and for that user I have placed the script in the startup applications.

#!/bin/bash
while  :
do
if !(ps -ae | grep teamviewer) then
/usr/bin/teamviewer 
/usr/bin/gnome-screensaver-command -a -l
fi
sleep 5
done