Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to set up lightdm to hibernate after, for example, 5 minutes without human activity? Only in LightDM without this behaviour after login? I whant to be able just logout to lightdm by pressing Ctrl+Alt+Del and it would hibernate after timeout automatically instead of power off or hibernate my computer.

share|improve this question

1 Answer 1

You could do this, but it won't be simple. First you can setup a script that runs when lightdm starts the display. Since it restarts the display when you logout, you'd write a small script that has a 5 minute timer in it that hibernates after a 5 minute delay. You'd set lightdm.conf to run this script by editing the config file like so:

display-setup-script=hibernate_delay.sh

You could then have a second script that lightdm runs when starting a user session that would cancel the timer. You set that in lightdm.conf as follows:

session-setup-script=cancel_hibernate.sh

As for the contents of those scripts, they could be simple. hibernate_delay.sh would be something like this, although you'd need to do the parts after the "touch" line in a second script that ran in the background:

#!/bin/sh
touch /tmp/hibernate_timer
sleep 300
if [ -f /tmp/hibernate_timer ];
then
  echo "5 minutes is up, hibernating"
  pmi action hibernate
else
  echo "hibernation cancelled"
fi

The cancel_hibernate.sh script would simply remove the hibernate_timer file so that it doesn't hibernate:

#!/bin/sh
rm -f /tmp/hibernate_timer

Now the theory here in my answer is sound, but I've not tried those scripts and like I mention above, the hibernate_delay.sh script needs to fork off a second script so that the sleep doesn't block. I'm sure there's also a better way to do this (using the command at is worth a look), but the hook-up points to lightdm would be the same.

Good Luck!

share|improve this answer
    
Beautiful! Big thanx! I'll try it! –  Pupizoid Jan 13 '13 at 12:11
    
it hangs up lightdm after reboot and after logout, I can see just blackscreen, but after hibernating that works perfect lightdm starts normal. I'll try to find errors in log-file. –  Pupizoid Jan 20 '13 at 7:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.