#! /bin/bash
#
# url.sh [url]
#
# 2017 Juli

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

screen -d -m -S mausdaemon_url
sleep 1
echo "screen-session fuer URL gestartet."

BENUTZER=`w | awk '$3==":0" { print $1 }' | head -1`
# screen -S mausdaemon_url -X stuff $"su -l $BENUTZER\n"
screen -S mausdaemon_url -X stuff $'export DISPLAY=:0\n'
screen -S mausdaemon_url -X stuff $"sudo -u $BENUTZER /usr/bin/firefox -new-tab '$1' & \n"
screen -S mausdaemon_url -X stuff $'exit\n'

exit 0

