#!/bin/bash
#
. /usr/share/groovix/global.conf


GX_SCREEN_LOCK_MAX_MINUTES=$1

echo "This screen has been locked for 0 minutes. In $GX_SCREEN_LOCK_MAX_MINUTES minutes this session will be closed." > ~/.groovix-screen-lock-time

for T in $(seq 1 $GX_SCREEN_LOCK_MAX_MINUTES) ; do 
	sleep 1m
	if [ $T -eq 1 ] ; then TPLURAL="" ; else TPLURAL="s" ; fi
	let REMAINING=GX_SCREEN_LOCK_MAX_MINUTES-T
	if [ $REMAINING -eq 1 ] ; then RPLURAL="" ; else RPLURAL="s" ; fi
	echo "This screen has been locked for $T minute$TPLURAL. In $REMAINING minute$RPLURAL this session will be closed." > ~/.groovix-screen-lock-time
done
rm -f ~/.xlockpw
killall xlock
groovix-session-forced-exit "The session was locked for the maximum amount of time and will be closed."
