- 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
And then just make it a startup application.
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
For the warning message, you can get really creative there. You could probably use Zenity if you wanted instead or maybe even you could embed the $DELAY variable in the warning message like "You will be logged out in $DELAY seconds".
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.




