After having looked at a number of options for shutting down after a certain time of inactivity, it seems that xautolock
is the easiest way. All credits to Sparhawk for mentioning about xautolock
.
Thanks to Sneetsher for pointing out to xscreensaver. Using xscreensaver, I could manually specify what to do after a certain amount of time of inactivity. To use xscreensaver, you need to install it using:
sudo apt-get install xscreensaver
or install it from the software center and then run it once using:
xscreensaver-demo
or type "xscreensaver" on the dash and open "Screensaver".
This will create a ~/.xscreensaver
file. Open it and search for the line:
programs: \
and add:
dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.PowerOff" boolean:true \n\
just below the
programs: \
line.
You can specify the time after which shutdown should be triggered by changing the line starting with timout
. Modify it to
timeout: 2:00:00
to shutdown after two hours.
Have a look at my .xscreensaver
file here.
This should poweroff your machine after two hours of inactivity or whatever time you specify in the script.
Notes:
Have a look at this question to see how to add xscreensaver on boot.
I tried using complex shutdown, but the bug here seems to affect me so could not happen. Otherwise, a graphical application would have been available for this.
This could be achieved using xautolock, however, as redanimalwar pointed, out a timout greater than 1 hour is not possible without modifying its source code and recompiling.
xautolock
is another option.