Power management: Difference between revisions
Prabuanand (talk | contribs) (moved content from Busybox acpid and updated wikilinks) |
Prabuanand (talk | contribs) (added content from Suspend on LID close) |
||
Line 5: | Line 5: | ||
Alpine Linux comes inbuilt with a basic version of [[#Busybox acpid|acpid]] as part of [[BusyBox]]. | Alpine Linux comes inbuilt with a basic version of [[#Busybox acpid|acpid]] as part of [[BusyBox]]. | ||
A flexible and extensible [https://sourceforge.net/projects/acpid2/ acpid2] daemon with Netlink support for delivering ACPI events can be installed with the {{pkg|acpid}} package:{{cmd|# apk add acpid}} | A flexible and extensible [https://sourceforge.net/projects/acpid2/ acpid2] daemon with Netlink support for delivering ACPI events can be installed with the {{pkg|acpid}} package:{{cmd|# apk add acpid}} On installation of this package, the inbuilt [[Busybox acpid|acpid]] daemon gets replaced by this. | ||
=== Power management utilities === | === Power management utilities === | ||
Line 51: | Line 51: | ||
When the power button is pressed, acpid runs script {{path|/etc/acpi/power}}. | When the power button is pressed, acpid runs script {{path|/etc/acpi/power}}. | ||
== Suspend when closing the LID == | |||
There are a few ways to Suspend a laptop when closing the LID of it. | |||
Installing a [[#Power management utilities|power management utility]] like {{pkg|zzz}} along with {{pkg|acpid}} package provides full support for pre/post suspend hooks etc. The [https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/acpid/handler.sh default handler script] ({{path|/etc/acpi/handler.sh}}) installed with the package {{pkg|acpid}} package provides out of the box support for suspend on LID closure. | |||
Alternately, this can be achieved using [[#Busybox acpid|Busybox acpid]] with a hook in {{path|/etc/acpi/LID/00000080}}. Make the hook executable:{{cmd|# chmod +x /etc/acpi/LID/00000080}} | |||
Ensure that the [[#Service configuration|acpid daemon service]] is running. | |||
Configuring with {{pkg|zzz}}:{{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
exec zzz | |||
}} | |||
Configuring with {{pkg|pm-utils}}: {{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
exec pm-suspend | |||
}} | |||
Configuring with ''' raw variant''': {{cat|/etc/acpi/LID/00000080|#!/bin/sh | |||
echo mem > /sys/power/state | |||
}} | |||
=== elogind and power management === | |||
If [[elogind]] is used, add the following line to {{Path|/etc/doas.conf}} config file {{Cat|/etc/doas.conf|... | |||
permit nopass $USER as root cmd /bin/loginctl | |||
}} | |||
You should now be able to [[#Suspend when closing the LID|suspend]] as a normal user, using the full path to executable. Refer to [[elogind]] page for more detailed information. | |||
== Handling the pressing of power button == | == Handling the pressing of power button == | ||
In case of desktop environments, it might be useful to allow for some control on what happens when you press the power button instead of shutting down the computer. This can be done via inbuilt Busybox [[#Busybox acpid|acpid]] by creating/modifying the hook in {{path|/etc/acpi/PWRF/00000080}}. | In case of desktop environments, it might be useful to allow for some control on what happens when you press the power button instead of shutting down the computer. This can be done via inbuilt Busybox [[#Busybox acpid|acpid]] by creating/modifying the hook in {{path|/etc/acpi/PWRF/00000080}}. Make the hook executable: {{cmd|# chmod +x /etc/acpi/PWRF/00000080}} | ||
Ensure that the [[#Service configuration|acpid daemon service]] is running. | |||
=== Configuring for shutdown === | === Configuring for shutdown === | ||
Line 66: | Line 94: | ||
zzz}} | zzz}} | ||
=== Disabling === | === Disabling the power button === | ||
To disable simply comment or remove the hook. This is useful to allow desktop environments like [[Gnome]] or [[KDE]] to handle the power button. {{cat|/etc/acpi/PWRF/00000080|#!/bin/sh | To disable simply comment or remove the hook. This is useful to allow desktop environments like [[Gnome]] or [[KDE]] to handle the power button. {{cat|/etc/acpi/PWRF/00000080|#!/bin/sh | ||
#Nothing}} | #Nothing}} | ||
== 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]] |
Revision as of 19:28, 2 May 2025
Power management is a feature of computer CPUs, GPUs and peripherals such as monitors and printers, that turns off the power or switches the system to a low-power state when inactive based on a standard called ACPI, which has superseded APM. This page explains how to configure what happens
Installation
Alpine Linux comes inbuilt with a basic version of acpid as part of BusyBox.
A flexible and extensible acpid2 daemon with Netlink support for delivering ACPI events can be installed with the acpid package:
# apk add acpid
On installation of this package, the inbuilt acpid daemon gets replaced by this.
Power management utilities
There are a number of power management utilities available in Alpine Linux.
Service configuration
Enable and start the acpid
daemon using the standard OpenRC commands:
# rc-update add acpid && rc-service acpid start
Busybox acpid
BusyBox acpid allows custom mapping and handling of ACPI events via options -M FILE
(Map file) and -a FILE
(Action file).
Map file
A Map file maps ACPI events to descriptions (the last column). For example:
Contents of /etc/acpi.map
The built-in map file contains only PWRB/PWRF (power button) and LID (lid close).
Action file
An Action file maps the event descriptions specified in the Map file to action scripts relative to the Config directory (/etc/acpi by default). It performs a substring match, so typically only the second part of the description is specified in the Action file. If the target path is not a file, but directory, it executes all scripts in the directory via run-parts. For example:
Contents of /etc/acpid.conf
When the power button is pressed, acpid runs script /etc/acpi/power.
Suspend when closing the LID
There are a few ways to Suspend a laptop when closing the LID of it.
Installing a power management utility like zzz along with acpid package provides full support for pre/post suspend hooks etc. The default handler script (/etc/acpi/handler.sh) installed with the package acpid package provides out of the box support for suspend on LID closure.
Alternately, this can be achieved using Busybox acpid with a hook in /etc/acpi/LID/00000080. Make the hook executable:
# chmod +x /etc/acpi/LID/00000080
Ensure that the acpid daemon service is running.
Configuring with zzz:
Contents of /etc/acpi/LID/00000080
Configuring with pm-utils:
Contents of /etc/acpi/LID/00000080
Configuring with raw variant:
Contents of /etc/acpi/LID/00000080
elogind and power management
If elogind is used, add the following line to /etc/doas.conf config file
Contents of /etc/doas.conf
You should now be able to suspend as a normal user, using the full path to executable. Refer to elogind page for more detailed information.
Handling the pressing of power button
In case of desktop environments, it might be useful to allow for some control on what happens when you press the power button instead of shutting down the computer. This can be done via inbuilt Busybox acpid by creating/modifying the hook in /etc/acpi/PWRF/00000080. Make the hook executable:
# chmod +x /etc/acpi/PWRF/00000080
Ensure that the acpid daemon service is running.
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
Configuring for sleep
Use one of the power management utility, say zzz here and Modify the hook as follows:
Contents of /etc/acpi/PWRF/00000080
Disabling the power button
To disable simply comment or remove the hook. This is useful to allow desktop environments like Gnome or KDE to handle the power button.
Contents of /etc/acpi/PWRF/00000080