Code: Select all
#!/bin/bash
MAXIDLE = 60000 #Maximum amount of idle time in milliseconds
while [ 1 ]; do
if [ `xprintidle` -gt $MAXIDLE ]; then
mate-session-save --force-logout #Whatever program you use to logout.
break
fi
sleep 1
done
You can even add a nested if loop, if you want like a warning message or something, like so:
Code: Select all
#!/bin/bash
MAXIDLE = 60000 #Maximum amount of idle time in milliseconds
DELAY = 30 #Amount of warning time you want to give
while [ 1 ]; do
if [ `xprintidle` -gt $MAXIDLE ]; then
notify-send "Foo" "Bar" -t `expr $DELAY '*' 1000` #Whatever warning message you want.
sleep $DELAY
if [ `xprintidle` -gt $MAXIDLE ]; then
mate-session-save --force-logout #Whatever program you use to logout.
break
fi
fi
sleep 1
done
Hope that helps you all out! This was one, of many, dead end threads I found, and I figure I can't be the only one who could really find this handy so hopefully I save other people some heartache.