Configure action when power-button is pressed

From Alpine Linux

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