25

I'm a new Ubuntu 13.10 user. Closing the lid of my laptop does not result in the computer entering suspend mode, meaning each time I close my lid without manually suspending the computer the battery dies.

The proper settings are set in Power Management -- suspend the laptop on lid close for both AC and DC, but these do not have an effect on actual behavior.

It looks like this is a common problem for many users as far back as Ubuntu 11 -- the only solution I could find is the below. However, as a new linux user I'm not aware of how to actually execute the instructions. If someone could provide additional detail that would be tremendously helpful.

Thanks in advance.

/etc/acpi/events/lidbtn triggers /etc/acpi/lid.sh which triggers
 /etc/acpi/local/lid.sh.post at the end of the script.
 /etc/acpi/local/* allows you to add your own config (e.g. required for
 wmii).

 generate /etc/acpi/local/lid.sh.post
 make it executable and add:

 \#!/bin/bash
 grep -q closed /proc/acpi/button/lid/*/state
 if [ $? = 0 ]
 then
 /usr/sbin/pm-suspend
 fi

 wmii will now go to suspend mode when closing the lid. It'll
 automatically wake up when opening the lid.
    #!/bin/bash

    load=$(cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/capacity)
    min_load=20
    if [ $load <= min_load ]; then
        pm-suspend
    fi

6 Answers 6

20

(Note that # before a command indicates that it should be run by the superuser, so replace the # with sudo.)

Open logind.conf as root: # vim /etc/systemd/logind.conf and remove the # before HandleLidSwitch=suspend. You can also change the option suspend to hibernate or poweroff

Fix from Launchpad Bug #863834, comment #30:

  1. Open a terminal: Ctrl + Alt + t
  2. # mkdir /etc/acpi/local
  3. # vim /etc/acpi/local/lid.sh.post
  4. Copy this short script:

     #!/bin/bash
     if grep -q closed /proc/acpi/button/lid/*/state
     then
         /usr/sbin/pm-suspend
     fi
    

    ... and paste it into vim by typing: "+p

  5. Save by typing ZZ (in capitals)
  6. # chmod 755 /etc/acpi/local/lid.sh.post (so it works even when power management is handled under the logged-in user instead of root)
12
  • ps: if you are not sure how to use vim then replace it with gedit and sudo with gksu
    – Meow
    Dec 25, 2013 at 3:41
  • Meow, thanks for the quick response. Unfortunately I'm still not 100% clear. Do I enter these commands in terminal? When I type 'sudo vim /etc/systemd/logind.conf', I get the error 'sudo: vim: command not found'. I'm also on a PC running linux, if that makes a difference. Dec 25, 2013 at 5:38
  • use sudo gedit /etc/systemd/logind.conf if vim is not installed & yes you need to enter them in the terminal
    – Meow
    Dec 25, 2013 at 10:21
  • Hrm still does not work. No change on lid close after restart. '#HandlePowerKey=poweroff #HandleSuspendKey=suspend #HandleHibernateKey=hibernate HandleLidSwitch=suspend' Dec 25, 2013 at 16:40
  • 1
    This worked for me, but I had to add the following: sudo chmod 755 /etc/acpi/local/lid.sh.post
    – qbert220
    Mar 23, 2015 at 16:14
5

In response to this post, I have had the same problem with this on my Toshiba Satellite a305-s6902 (which I purchased solely to practice on Linux), and found that this worked for me:

sudo vim /etc/systemd/logind.conf

then as above, remove the # before HandleLidSwitch=suspend and save (ESC :wq).

HOWEVER ---> I find that I must put the computer into suspend manually FIRST, and after every reboot to engage the trigger. I do not know why, but this has worked consistently for me.

1

I've solve it by uncommenting variable LID_SLEEP=true from /etc/default/acpi-support.

1
  • 2
    this variable isn't available in 16.04 Aug 30, 2016 at 2:25
1

I had the same problem with Linux Mint Cinnamon 17.2. Since it's based on Ubuntu 14.04 I expect many things are much the same.

Having searched the suspend on lid closed problem I found myself here and up until then, the best I had come up with was to manually suspend the first time after a boot and afterwards the closed lid would suspend. Having read through these posts and comments I believe I've resolved the issue.

Here's what I did:

  1. Opened a terminal session and, using nano instead of vim, typed;

    sudo nano /etc/systemd/logind.conf
    
  2. As suggested, I removed the # before HandleLidSwitch=suspend. Then I saved it.

  3. Then I typed...

    mkdir /etc/acpi/local
    sudo nano /etc/acpi/local/lid.sh.post
    

    ...and copied and pasted the next 5 lines previously posted

    #!/bin/bash
    if grep -q closed /proc/acpi/button/lid/*/state
    then
        sudo /usr/sbin/pm-suspend
    fi
    

    NOTE: To make this work I added the sudo to the line /usr/sbin/pm-suspend. Otherwise it would not run.

  4. Finally I saved it and as previously posted, typed; the logged-in user instead of root, typed;

    sudo chmod 755 /etc/acpi/local/lid.sh.post
    

Unfortunately, this did not work. I did some tests, however, on the commands in the script and they did work so I decided something else wasn't triggering them. Further down the posts I came across a reference to a Gnome power manager bug:

https://bugs.launchpad.net/ubuntu/+source/upower/+bug/863834

Particularly interesting was a post by Michael Backhaus on 2012-06-09 in which he wrote:

/etc/acpi/events/lidbtn triggers /etc/acpi/lid.sh which triggers /etc/acpi/local/lid.sh.post.

Following this was an almost identical version of the above bash script, lid.sh.post.

In this version of Mint, /etc/acpi/events/lidbtn and /etc/acpi/lid.sh did not exist. However, /etc/acpi/events/powerbtn and /etc/acpi/powerbtn.sh did. A look at "powerbtn" provided an answer

This is my work-around:

  1. To create a custom "lidbtn", typed;

    sudo nano /etc/acpi/events/powerbtn
    

    and modified it to like this for lidbtn;

    # /etc/acpi/events/lidbtn
    # This is called when the user closes the lid and calls
    # /etc/acpi/lidbtn.sh for further processing.
    
    # Optionally you can specify the placeholder %e. It will pass
    # through the whole kernel event message to the program you've
    # specified.
    
    # We need to react on "button lid.*" and "button/lid.*" because
    # of kernel changes.
    
    event=button[ /]lid
    action=/etc/acpi/lidbtn.sh
    
  2. I saved it. Then copied /etc/acpi/local/lid.sh.post to /etc/acpi/ and renamed it lidbtn.sh.

I rebooted and now closing the lid always suspends my laptop. However, I have to manually wake it up when opening the lid. Next project to work on.

ADDENDUM: I should add that I do not have a second monitor. For me, the problem was that suspend simply did not work when the lid was closed.

1
  • Did this work for Linux Mint 18 "Sarah"? And @bob-el did you find out the workaround for wake up as well? Aug 2, 2016 at 2:49
0

For me the problem was that the lid close is handled different when an external monitor is connected. So changing that option as user in dconf-editor solved the problem for me:

Schema:

org.cinnamon.settings-daemon.plugins.power

or (depending on what desktop environment you use)

org.gnome.settings-daemon.plugins.power

Name:

lid-close-suspend-with-external-monitor

Set to:

true

Description:

With no external monitors plugged in, closing a laptop's lid will suspend the machine (as set by the lid-close-battery-action and lid-close-ac-action keys). By default, however, closing the lid when an external monitor is present will not suspend the machine, so that one can keep working on that monitor (e.g. for docking stations or media viewers). Set this key to False to keep the default behavior, or to True to suspend the laptop whenever the lid is closed and regardless of external monitors.

0

I am using Mint 18.1 on Macbook Air 6,2. Here is the solution I have and it works nearly perfect.

I use mba6x_bl to fix my MBA black screen when waking up. Follow their instructions.

Then use Bob-El's solution above to solve suspend problem.

  • backup and open /etc/acpi/events/powerbtn
    sudo cp /etc/acpi/events/powerbtn /etc/acpi/events/powerbtn_bak
    sudo nano /etc/acpi/events/powerbtn
  • replace contents of powerbtn with text below

    # /etc/acpi/events/lidbtn
    # This is called when the user closes the lid and calls  
    # /etc/acpi/lidbtn.sh for further processing.  
    # Optionally you can specify the placeholder %e. It will pass  
    # through the whole kernel event message to the program you've  
    # specified.  
    # We need to react on "button lid.*" and "button/lid.*" because  
    # of kernel changes.  
    event=button[ /]lid  
    action=/etc/acpi/lidbtn.sh
    
  • create /etc/acpi/lidbtn.sh

    sudo nano /etc/acpi/lidbtn.sh
    
  • place the following text into it

    #!/bin/bash
    if grep -q closed /proc/acpi/button/lid/*/state
      then
      /usr/sbin/pm-suspend
    fi
    
  • Open Power Management -> On AC Power -> Actions -> When laptop lid is closed, choose Blank screen. This will keep MBA suspend when connecting to power.

The only problem I have noticed is when MBA suspended with power connected, its keyboard light will be automatically on. But other than that, everything works well.

You must log in to answer this question.

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