#!/bin/bash

if [ -z "$X2GO_SESSION" ] ; then
	echo "Not an x2go session -> Not starting autosuspend."
	exit
fi

AUTOSUSPEND_TIME=""

# if configuration file exists, read it
if [ -e "$HOME/.config/x2go-autosuspend-time" ] ; then
	AUTOSUSPEND_TIME="$(head -n 1 "$HOME/.config/x2go-autosuspend-time" | grep '^[0-9]*$' )"
fi

[ -n "$AUTOSUSPEND_TIME" ] || AUTOSUSPEND_TIME="21"

xautolock -time "$AUTOSUSPEND_TIME" -locker x2gosuspend-session
