Page 1 of 1

HOWTO: Laptop suspend on lid down.

Posted: Thu Feb 12, 2015 10:00 pm
by wuxmedia
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.

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 8:55 am
by wuxmedia
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

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 9:44 am
by machinebacon
^ yup, same here on Toshiba R500.

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

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

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 9:58 am
by wuxmedia
^ 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.

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 10:27 am
by machinebacon
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).

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 11:08 am
by wuxmedia
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

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 11:10 am
by machinebacon
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) ;)

Re: HOWTO: Laptop suspend on lid down.

Posted: Fri Jul 15, 2016 8:36 pm
by wuxmedia
^ 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>

Re: HOWTO: Laptop suspend on lid down.

Posted: Sat Jul 16, 2016 6:09 am
by machinebacon
<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>

Re: HOWTO: Laptop suspend on lid down.

Posted: Sat Jul 16, 2016 7:35 am
by wuxmedia
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.

Re: HOWTO: Laptop suspend on lid down.

Posted: Sat Jul 16, 2016 12:31 pm
by machinebacon
/me Feeling old now.