Ubuntu 17.10 laptop doesn't suspend on lid close

Thinkpad T450 running Ubuntu 17.10 which was clean-installed (not upgraded) some weeks back. I frequently moved from room to room and like the laptop to go to sleep when I close the lid. It seems to never do this, staying awake all the time. I have to hold down the power button in the indicator and choose the pause icon to suspend it. Previous releases of Ubuntu used to "Just Work".

I have tried toggling the option in Tweaks to ensure it is set to suspend on lid close, but this makes no difference. Is this a bug or expected behaviour?


Solution 1:

Turns out we were all wrong. The magnet which triggers the lid sensor had come away inside the laptop. I confirmed this by holding a fridge magnet up to the camera. As soon as I did that, the laptop suspended fine. So I figured there's a magnet in the base. There was, but it was floating around (clinging to the battery) inside the machine. I put it back in place and it's now working.

enter image description here

Solution 2:

We can catch the lid open/close events and could bind scripts to them by using acpid - Advanced Configuration and Power Interface event daemon.

  • In attempt to check whether this suggestion works I've installed Ubuntu 17.10 on my DELL Vostro 3350. Then I've used dconf-editor to disable the lid close action. But unfortunately I can't disable this action... So I just hope this could help you.

1. Catch the events. Execute one of the next commands, then close and open the lid: acpi_listen or netcat -U /var/run/acpid.socket. Here is an example output:

$ acpi_listen
button/lid LID close
button/lid LID open

2. Configure acpid to recognize the events triggered when the device mode is changed. Create the following files (don't forgot to use the actual events from the above step):

  • /etc/acpi/events/lid-close:

    # /etc/acpi/events/lid-close 
    # This is called when the lid is closed
    event=button/lid LID close
    action=/etc/acpi/lid-actions.sh 1
    
  • /etc/acpi/events/lid-open:

    # /etc/acpi/events/lid-open
    # This is called when the lid is open
    event=button/lid LID open
    action=/etc/acpi/lid-actions.sh 0
    

3. Restart acpid so it can re-read the event filters, including the ones we just added:

sudo systemctl restart acpid.service

4. Create the script /etc/acpi/lid-actions.sh (and make it executable) that will suspend the laptop when the lid is close 1. I don't have idea what action could be useful when the lid is going to be open 0, so these lines are commented.

#!/bin/sh
if [ "${1}" -eq 1 ]; then systemctl suspend  # Lid is close
#elif [ "${1}" -eq 0 ]; then                 # Lid is open
fi

References:

  • How do I disable the touchpad when the lid is twisted or closed? This is the main source.
  • ThinkWiki: Installing Ubuntu 12.10 on Thinkpad Twist | Thinkpad-acpi | Wacom Tablet Stilus
  • How can I suspend/hibernate from command line?
  • How do I re-activate (wake?) the monitors from the command line - not implemented here.