Suspend on LID close: Difference between revisions

From Alpine Linux
m (→‎Busybox acpid: Use rc-service instead of calling the init script directly.)
(prefix commands with #)
Line 4: Line 4:


[https://sourceforge.net/projects/acpid2/ acpid2] (provided by package {{pkg|acpid}}) is a flexible and extensible daemon with Netlink support for delivering ACPI events.
[https://sourceforge.net/projects/acpid2/ acpid2] (provided by package {{pkg|acpid}}) is a flexible and extensible daemon with Netlink support for delivering ACPI events.
The [https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/acpid/handler.sh default handler script] (<code>/etc/acpi/handler.sh</code>) installed with the package provides support for suspend on LID close out of the box.
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.
We recommend installing {{pkg|zzz}} along with {{pkg|acpid}} to get support for pre/post suspend hooks etc.
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}}
# 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}}
# Enable and start the acpid daemon: {{cmd|# rc-update add acpid && rc-service acpid start}}


== Busybox acpid ==
== Busybox acpid ==
Line 14: Line 14:
This can be done via [[Busybox acpid]] with a hook in {{path|/etc/acpi/LID/00000080}}:
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
# '''with zzz:'''{{cmd|# apk add zzz}} {{cat|/etc/acpi/LID/00000080|#!/bin/sh
exec zzz
exec zzz
}}
}}
# '''or with pm-utils:''' {{cmd|apk add pm-utils}} {{cat|/etc/acpi/LID/00000080|#!/bin/sh
# '''or with pm-utils:''' {{cmd|# apk add pm-utils}} {{cat|/etc/acpi/LID/00000080|#!/bin/sh
exec pm-suspend
exec pm-suspend
}}
}}
Line 25: Line 25:


Make the hook executable:
Make the hook executable:
{{cmd|chmod +x /etc/acpi/LID/00000080}}
{{cmd|# chmod +x /etc/acpi/LID/00000080}}


That should be it. To make sure that the acpid daemon is running, execute:
That should be it. To make sure that the acpid daemon is running, execute:
{{cmd|rc-service acoud start}}
{{cmd|# rc-service acoud start}}


= See Also =
= See Also =

Revision as of 11:16, 25 September 2023

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.

  1. Install acpid and zzz:

    # apk add acpid zzz

  2. 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:

  1. with zzz:

    # apk add zzz

    Contents of /etc/acpi/LID/00000080

    #!/bin/sh exec zzz
  2. or with pm-utils:

    # apk add pm-utils

    Contents of /etc/acpi/LID/00000080

    #!/bin/sh exec pm-suspend
  3. 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 acoud start

See Also