Suspend on LID close: Difference between revisions
m (Minor amendments; categorized: Power Management) |
Cyclisme24 (talk | contribs) m (→Busybox acpid) |
||
(14 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
This article explains how to make your laptop go to Suspend when closing the LID. | This article explains how to make your laptop go to Suspend when closing the LID. | ||
== acpid2 == | |||
''' | [https://sourceforge.net/projects/acpid2/ acpid2] (provided by package {{pkg|acpid}}) is a flexible and extensible daemon with Netlink support for delivering ACPI events. | ||
{{cmd|apk add pm-utils}} | The [https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/acpid/handler.sh default handler script] ({{path|/etc/acpi/handler.sh}}) installed with the package provides support for suspend on LID close out of the box. | ||
{{cat|/etc/acpi/LID/00000080|#!/bin/sh | We recommend installing {{pkg|zzz}} along with {{pkg|acpid}} to get support for pre/post suspend hooks etc. | ||
# Install {{pkg|acpid}} and {{pkg|zzz}}: {{cmd|# apk add acpid zzz}} | |||
# Enable and start the acpid daemon: {{cmd|# rc-update add acpid && rc-service acpid start}} | |||
== Busybox acpid == | |||
This can be done via [[Busybox acpid]] with a hook in {{path|/etc/acpi/LID/00000080}}: | |||
# '''with zzz:'''{{cmd|# apk add zzz}} {{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
exec zzz | |||
}} | |||
# '''or with pm-utils:''' {{cmd|# apk add pm-utils}} {{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
exec pm-suspend | exec pm-suspend | ||
}} | }} | ||
# '''or with raw variant''': {{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
''' | |||
{{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
echo mem > /sys/power/state | echo mem > /sys/power/state | ||
}} | }} | ||
Make the hook executable: | |||
{{cmd|# chmod +x /etc/acpi/LID/00000080}} | |||
That should be it. To make sure that the acpid daemon is running, execute: | |||
{{cmd|# rc-service acpid start}} | |||
== elogind == | |||
Use elogind to trigger suspend and use doas to grant normal user such permissions. | |||
Install elogind: | |||
apk add elogind | |||
rc-update add elogind | |||
rc-service elogind start | |||
Now suspend on lid close should be working as expected. | |||
For normal user to trigger suspend, install doas: | |||
apk add doas | |||
Configure doas in <code>/etc/doas.conf</code>: | |||
permit nopass $USER as root cmd /bin/loginctl | |||
You should now be able to suspend the computer as a normal user, using the full path to executable. | |||
= See Also = | |||
* [https://github.com/jirutka/zzz zzz] | |||
* [https://unix.stackexchange.com/questions/484550/pm-suspend-vs-systemctl-suspend pm-suspend vs systemd...] | |||
* [https://wiki.archlinux.org/index.php?title=Pm-utils&oldid=498864 Archwiki pm-utils (archived page)] | |||
[[Category:Power Management]] | [[Category:Power Management]] | ||
[[category: Desktop]] |
Latest revision as of 16:44, 26 June 2024
This article explains how to make your laptop go to Suspend when closing the LID.
acpid2
acpid2 (provided by package acpid) is a flexible and extensible daemon with Netlink support for delivering ACPI events. The default handler script (/etc/acpi/handler.sh) installed with the package provides support for suspend on LID close out of the box. We recommend installing zzz along with acpid to get support for pre/post suspend hooks etc.
- Install acpid and zzz:
# apk add acpid zzz
- Enable and start the acpid daemon:
# rc-update add acpid && rc-service acpid start
Busybox acpid
This can be done via Busybox acpid with a hook in /etc/acpi/LID/00000080:
- with zzz:
# apk add zzz
Contents of /etc/acpi/LID/00000080
#!/bin/sh exec zzz - or with pm-utils:
# apk add pm-utils
Contents of /etc/acpi/LID/00000080
#!/bin/sh exec pm-suspend - or with raw variant:
Contents of /etc/acpi/LID/00000080
#!/bin/sh echo mem > /sys/power/state
Make the hook executable:
# chmod +x /etc/acpi/LID/00000080
That should be it. To make sure that the acpid daemon is running, execute:
# rc-service acpid start
elogind
Use elogind to trigger suspend and use doas to grant normal user such permissions.
Install elogind:
apk add elogind rc-update add elogind rc-service elogind start
Now suspend on lid close should be working as expected.
For normal user to trigger suspend, install doas:
apk add doas
Configure doas in /etc/doas.conf
:
permit nopass $USER as root cmd /bin/loginctl
You should now be able to suspend the computer as a normal user, using the full path to executable.