HOWTO: session lock after teamviewer-session

This is a workaround for teamviewer not locking user’s desktop-session after disconnect.

since version 8 there was no more function like that.

this workaround aims at single-seated desktop environments only , please feel free to access latest version of the script at my GITHUP.

to daemonize the script, I used the ‘daemon’-tool from libslack // http://libslack.org/daemon/

locktvd.sh

 

to keep it starting at session-start, put it into ~/.profile like

daemon -n TVLOCKD ~/bin/locktvd.sh

#!/bin/bash
TVVERSION=`teamviewer version |cat -e - |grep -i teamviewer |awk '{print $4}'|cut -d. -f1`
TVLOG="/opt/teamviewer/logfiles/TeamViewer${TVVERSION}_Logfile.log"
PATTERN="CStreamManager::ParticipantRemoved:"
MYUSER=`whoami`
MYSESSION=`loginctl list-sessions |grep $MYUSER|grep seat |grep -v "\ 1\ "|awk '{print $1}'`

tail -fn0 ${TVLOG} | \
while read line ; do
echo "$line" | grep -q "${PATTERN}"
if [ $? = 0 ]; then
sudo `which loginctl` lock-session ${MYSESSION}
fi
done