HOWTO: Laptop suspend on lid down.

Forum rules
Share your brain ;)
User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

HOWTO: Laptop suspend on lid down.

Unread post by wuxmedia » Thu Feb 12, 2015 10:00 pm

For my own reference really there are a million versions out there.:
written in a bizarre one liner style:

Code: Select all

 sudo echo "echo mem > /sys/powerstate/class" > /etc/acpi/sleep.sh; sudo echo -e "/etc/acpi/events/lid\nevent=button/lid LID close\naction=/etc/acpi/sleep.sh" > /etc/acpi/events/lid; sudo chmod a+x /etc/acpi/sleep.sh
reboot, or maybe even logout.
Not even sure about the pm-utils if they are only hack around scripts.
purged pm-utils, seemed not to need them. Cool.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by wuxmedia » Fri Jul 15, 2016 8:55 am

just had to refer to this and it's wrong now.
I installed apci-support which did a good job, except didn't suspend the laptop, so i kicked the script and used this one instead:

Code: Select all

#!/bin/bash
echo mem > /sys/power/state
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by machinebacon » Fri Jul 15, 2016 9:44 am

^ yup, same here on Toshiba R500.

https://bbs.archlinux.org/viewtopic.php?id=102307

I'm usually with pm-utils (only), but YMMV.
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by wuxmedia » Fri Jul 15, 2016 9:58 am

^ yeah package 'acpi-support' gives scripts which calls (and presumably depends) upon pm-suspend.

Code: Select all

tdh@dimholt:~/work/htdocs$ depends acpi-support
acpi-support
  Depends: acpid
  Conflicts: uswsusp
  Recommends: toshset
  Recommends: wireless-tools
    wireless-tools:i386
tdh@dimholt:~/work/htdocs$ depends acpid
acpid
  Depends: libc6
  Depends: init-system-helpers
  Depends: lsb-base
  Depends: kmod
    kmod:i386
or not... still it works, leaving it.
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by machinebacon » Fri Jul 15, 2016 10:27 am

Seems that pm-utils only comes with pm-hibernate and pm-suspend, so no acpi daemon running in the background to check for lid state (/proc/acpi/button/lid/LID/state).
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by wuxmedia » Fri Jul 15, 2016 11:08 am

Sure, I alias a letter to pm-suspend if I haven't worked that out, just feels to me like it's an integral part of having a laptop, slamming the lid shut then leaving it.
acpi-support some how manged to not suspend, but it did lock the screen, which was quite nice. no idea how it found i3lock, rather than screensaver.
anyway
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by machinebacon » Fri Jul 15, 2016 11:10 am

Something like Ctrl-Alt-Esc that calls a bunch of scripts :D Golden days of 3-finger-reset (nah, I don't mean Ctrl-Alt-Bksp) ;)
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by wuxmedia » Fri Jul 15, 2016 8:36 pm

^ macs had a plethora of those, ctl-option-esc the type 'G FINDER' sometimes resets the desktop, back in the macOS9.2 (and before days)
<rant>
um so I took a bit of time wondering why this fancy pants script (installed by acpi-support) didn't work
so looking at the lid down bit (/etc/acpi/lid.sh):

Code: Select all

#!/bin/sh

test -f /usr/share/acpi-support/state-funcs || exit 0

. /usr/share/acpi-support/power-funcs
. /usr/share/acpi-support/policy-funcs
. /etc/default/acpi-support

[ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre
if { CheckPolicy || HasLogindAndSystemd1Manager; }; then
        exit
fi
grep -q closed /proc/acpi/button/lid/*/state
if [ $? -eq 0 ]
then
    . /usr/share/acpi-support/screenblank
    if [ x$LID_SLEEP = xtrue ]; then
        pm-suspend
        if [ $? -ne 0 -a x$LID_SHUTDOWN = xtrue ]; then
                shutdown -P now
etc....
That made me look at those 'sourced' file.
(dot is not the clearest of indicators there)
and have to uncomment as it says:

Code: Select all

# Uncomment this to enable ACPI sleep when the lid screen is closed.
LID_SLEEP=true
Because of course, why would you want your laptop to not suspend on lid down by default?
like every laptop in the world ever? That to me is expected, nay - required after you'd installed the damn thing. but, by default you DO want the screenlocker to kick in (it checks for various ones running in a separate script) because, you know that is normal...?
</rant>
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by machinebacon » Sat Jul 16, 2016 6:09 am

<rant>
^ Unbelievable. Might be because on some laptops X doesn't come back alive after suspend? So why fix the X-after-suspend problem if you can simply hide this in /etc/default/acpi-support where nobody looks :D Anyway I wonder why it calls pm-suspend, that is part of pm-utils, but doesn't depend on it. WTF? Where does pm-suspend come from if there is no pm-suspend on the puter?

Google for "enable ACPI sleep when the lid screen is closed debian" and you get 150.000 results. It's embarrassing. It is clearly a well-known problem that this shit doesn't work as users expect it. "Simply install a power-manager that handles that for you", oh fuck you, no I won't :D
</rant>
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by wuxmedia » Sat Jul 16, 2016 7:35 am

bacon wrote:because on some laptops X doesn't come back alive after suspend?
That must be it.
If one is venturing into 'no DM/PM' territory (I remember the thread where this all started) then one must have one's wits about them.
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Laptop suspend on lid down.

Unread post by machinebacon » Sat Jul 16, 2016 12:31 pm

/me Feeling old now.
..gnutella..

Post Reply