Laptop does not suspend when lid is closed

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

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.