6

Ok, I know there already are several questions related to this. I tried many solutions to no avail. I'm going to detail here what I did and how are my config files in the hope that a good soul will point out what I missed.

Some initial information:

  • I installed Ubuntu 14 from a 14.01 .iso and it became a 14.04 because, I guess, I checked an option to update automatically during the install.
  • I have an external monitor attached. This seems to be relevant in some cases.
  • As explaned here, there is no option to make the PC hibernate in the power settings of Ubuntu 14. Only suspend and do nothing.
  • pm-hibernate works fine.
  • My swap is slightly larger than my RAM

1. I had a Mint (14 if I'm not mistaken) where closing the lid would not hibernate until I added some scripting. In Ubuntu 14 there is no /etc/acpi/lid.sh that I can edit as I did in Mint. I tried to create one with the following contents:

echo 'ok' > ok
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
    su - gabriel -c 'dconf read /org/gnome/settings-daemon/plugins/power/lid-close-ac-action' | grep hibernate
    if [ $? = 0 ]
    then
        pm-hibernate
    fi
fi

The file ok is not created when I close the lid, this means the script is never called.

I tried to move lid.sh into events/.

As suggested here, I tried to rename it to lid.sh.post and to move it to /etc/acpi/local/, and other several combinations of directory and names (with/without .post, in /etc/acpi/, local/, events/...)

2. I did as told here and installed gnome-tweak-tool, so I could set the action on closed lid to hibernate. After I did, the dropdowns in the control panel / power were blank (not suspend nor 'do nothing'), but now they show 'do nothing' again, I don't know what I did to change that. And running

su - gabriel -c 'dconf read /org/gnome/settings-daemon/plugins/power/lid-close-ac-action'

still returns 'nothing', which compromises my (probably useless anyway) script.

3. I did as told here: edited /etc/systemd/logind.conf and set HandleLidSwitch to 'hibernate':

cat /etc/systemd/logind.conf | grep -i lid
#HandleLidSwitch=hibernate
#LidSwitchIgnoreInhibited=yes

I also tried with

#LidSwitchIgnoreInhibited=no

4. As explained here and here, I edited /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla:

root@gabriel-linux:/var/lib/polkit-1/localauthority/50-local.d# cat com.ubuntu.enable-hibernate.pkla 
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes
7
  • do you have a swap partition at least as large as your ram?
    – sbergeron
    Aug 29, 2014 at 17:57
  • @sbergeron, yes
    – Gabriel
    Aug 29, 2014 at 19:00
  • is it mounted when you try to hibernate?
    – sbergeron
    Aug 29, 2014 at 19:01
  • Not sure how to check that... The Disks utility says it's "active". Is that ok ?
    – Gabriel
    Aug 29, 2014 at 19:07
  • go into gparted and right click then if it says swapkon click it to turn it on and try again
    – sbergeron
    Aug 29, 2014 at 19:09

2 Answers 2

4

For my script (lid.sh) to be called in /etc/acpi/, I had to create the correct file in /etc/acpi/events/.

The file has to be called lm_lid and the content is as follows:

event=button/lid.*
action=/etc/acpi/lid.sh

Reboot your system to let this take effect.

Note: I moved back to Linux Mint (now 17) before I figured this all out, and this, with the correct file, now works. I'd like to hear from Ubuntu users though.

1
1

I had a similar problem in Linux Mint 17.3. It went away when I installed the nvidia video driver in the place of the default open source one. (Administration->Driver Manager->Select nvidia recommended driver)

You must log in to answer this question.

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