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.

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.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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.)

share|improve this answer
add comment

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.

share|improve this answer
    
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 '12 at 9:23
    
Tried it again just now, it shuts my laptop down. –  GUI Junkie Oct 27 '12 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.) –  thirtythreeforty Oct 27 '12 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! –  Adam Paetznick Oct 27 '12 at 19:58
    
@adam Ah, ok, didn't think of that. Edited, thanks. –  thirtythreeforty Oct 27 '12 at 20:38
show 1 more comment

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.