#! /bin/bash
#
# freigeben.sh
#
# Script für MAus
#
# Version 0.3 Jan'2017

x_pid=`ps -ef | grep "X :1" | grep -v "grep" | awk '{print $2}'`
if [ "$x_pid" = "" ]; then
  x_pid=`ps -ef | grep "Xorg :1" | grep -v "grep" | awk '{print $2}'`
fi

kill $x_pid

sleep 1

for session in $(screen -ls | grep -o '[0-9]\+\.mausdaemon_slock')
do
  echo "beende $session ..."
  screen -S "${session}" -X quit
done

exit 0
