4

Every once in a while my SO-User (significant other user) leaves the computer but doesn't hibernate it. I want to push the power button to save some energy, but as I'm not in her session, the computer doesn't respond.

Is there a way to configure Ubuntu 11.10 to hibernate whenever the power button is pushed?

I already applied this solution, but that only works inside a session.

2 Answers 2

2

I don't know the answer to the specific question you asked, but you can set the computer to automatically suspend after a set idle time:

  1. Open "System Settings" from the power/gear menu (top right in Unity).

  2. Click "Power"

  3. Choose a suitable timeout.

Suspend isn't quite the same as hibernate, and there's no manual "do it now" feature, but it'll still save you power.

(Alternatively, you could log yourself in, and suspend it from your own session. Your SO would have to switch back to her own session when she returns.)

2
+50

After reading through Ubuntu's acpi setup, it seems like the issue is that when the login manager is running, there is no suitable handler running. So, according to the nicely-commented /etc/acpi/powerbtn.sh, it defaults to just shutting down the computer. You'd like to change this behavior? I think you just need to remove the final line of powerbtn.sh:

/sbin/shutdown -h now "Power button pressed"

and insert

/usr/sbin/pm-hibernate

above the handlers for X power management daemons (the three lines of comments), like this:

   ...
   test -f /var/lock/acpisleep && exit 0

-> pm-hibernate

   # If the current X console user is running a power management daemon that
   ...

and ACPI will invoke hibernation instead using your DE's power handling. Note that this change will affect all ttys, not just the X tty. That is, the power button will hibernate the computer when you're in tty1. If you're like most Ubuntu users, this isn't a deal breaker, because most people (myself included) spend 99% of their time in X.

6
  • Looks good, but... I'm running 12.04 now and I don't have the hibernate option at all! (I tried this solution)
    – GUI Junkie
    Oct 27, 2012 at 9:23
  • Tried it again just now, it shuts my laptop down.
    – GUI Junkie
    Oct 27, 2012 at 9:29
  • Oh, I see. You need to get hibernation working from within a session first. I'm not really familiar with Ubuntu's policies; with my Arch Linux box I had to add resume=/dev/sda4 to my kernel parameters in /etc/default/grub. (sda4 is my swap partition.) Oct 27, 2012 at 17:55
  • 1
    I'm using Ubuntu 12.10. The answer almost works for me. If gnome is running, then the last line of powerbtn.sh is never reached. This is true even if the gnome session is locked, or when in tty1. I have to insert the /usr/sbin/pm-hibernate line in the middle of the script, before the test for gnome-settings-manager etc. Of course, this is a hack since it bypasses gnome altogether. But it works! Oct 27, 2012 at 19:58
  • @adam Ah, ok, didn't think of that. Edited, thanks. Oct 27, 2012 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .