#!/bin/bash
. /etc/groovix/pac.conf

MAX_MINUTES=$1

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

for T in $(seq 1 $MAX_MINUTES) ; do 
	sleep 1m
	if [ $T -eq 1 ] ; then TPLURAL="" ; else TPLURAL="s" ; fi
	let REMAINING=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."
