Configure action when power-button is pressed

From Alpine Linux
Revision as of 00:49, 29 February 2024 by Ncrav (talk | contribs) (Add instructions on how to configure the action for when the power button is pressed)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This article explains how to configure what happens when you press the power button. This might be useful to allow for desktop environments to control what happens instead of shutting down.

  1. Install acpid:

    # apk add acpid

  2. Enable and start the acpid daemon:

    # rc-update add acpid && rc-service acpid start

Busybox acpid

This can be done via Busybox acpid by creating/modifying the hook in /etc/acpi/PWRF/00000080.

Configuring for shutdown

In a newly installed system this might be already defined, however you can create the hook as follows:

Contents of /etc/acpi/PWRF/00000080

#!/bin/sh poweroff

Configuring for sleep

  1. Install zzz:

    # apk add zzz

  2. Modify the hook as follows:

    Contents of /etc/acpi/PWRF/00000080

    #!/bin/sh zzz

Disabling

To disable simply comment or remove the hook. This is useful to allow desktop environments to handle the power button.

Contents of /etc/acpi/PWRF/00000080

#!/bin/sh #Nothing