Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end The purpose of this page is to provide general overview of power management in Arch Linux. As Arch Linux uses systemd as system manager, this article focuses on it.
There are multiple places where one can change power management settings:
There are also many power management tools:
- 1 Power management with systemd
- 2 Troubleshooting
- 3 See Also
Power management with systemd
systemd handles some power-related ACPI events. They can be configured via the following options from
HandlePowerKey: specifies which action is invoked when the power key is pressed.
HandleSuspendKey: specifies which action is invoked when the suspend key is pressed.
HandleHibernateKey: specifies which action is invoked when the hibernate key is pressed.
HandleLidSwitch: specifies which action is invoked when the lid is closed.
The specified action can be one of
If these options are not configured, systemd will use its defaults:
In the current version of systemd, the
Handle* options will apply throughout the system unless they are "inhibited" (temporarily turned off) by a program, such as a power manager inside a desktop environment. If these inhibits are not taken, you can end up with a situation where systemd suspends your system, then when it wakes up the other power manager suspends it again.
ignoreif you want your ACPI events to be handled by Xfce, acpid or other programs.
systemctl hibernate to work on your system you need to follow the instructions at Pm-utils#Hibernation (suspend2disk) and possibly at Pm-utils#Mkinitcpio Resume Hook (pm-utils does not need to be installed).
systemd does not use pm-utils to put the machine to sleep when using
systemctl hibernate or
systemctl hybrid-sleep; pm-utils hooks, including any custom hooks, will not be run. However, systemd provides two similar mechanisms to run custom scripts on these events.
Suspend/resume service files
Service files can be hooked into suspend.target, hibernate.target and sleep.target to execute actions before or after suspend/hibernate. Separate files should be created for user actions and root/system actions. To activate the user service files run
systemctl enable suspend@user && systemctl enable resume@user. Examples:
[Unit] Description=User suspend actions Before=sleep.target [Service] User=%I Type=forking Environment=DISPLAY=:0 ExecStartPre= -/usr/bin/pkill -u %u unison ; /usr/local/bin/music.sh stop ; /usr/bin/mysql -e 'slave stop' ExecStart=/usr/bin/sflock [Install] WantedBy=sleep.target
[Unit] Description=User resume actions After=suspend.target [Service] User=%I Type=simple ExecStartPre=/usr/local/bin/ssh-connect.sh ExecStart=/usr/bin/mysql -e 'slave start' [Install] WantedBy=suspend.target
For root/system actions (activate with
systemctl enable root-suspend):
[Unit] Description=Local system resume actions After=suspend.target [Service] Type=simple ExecStart=/usr/bin/systemctl restart mnt-media.automount [Install] WantedBy=suspend.target
[Unit] Description=Local system suspend actions Before=sleep.target [Service] Type=simple ExecStart=-/usr/bin/pkill sshfs [Install] WantedBy=sleep.target
A couple of handy hints about these service files (more in
Type=OneShotthen you can use multiple
ExecStart=lines. Otherwise only one
ExecStartline is allowed. You can add more commands with either
ExecStartPreor by separating commands with a semicolon (see the first example above; note the spaces before and after the semicolon, as they are required).
- A command prefixed with
-will cause a non-zero exit status to be ignored and treated as a successful command.
- The best place to find errors when troubleshooting these service files is of course with journalctl.
Combined Suspend/resume service file
With the combined suspend/resume service file, a single hook does all the work for different phases (sleep/resume) and for different targets (suspend/hibernate/hybrid-sleep).
Example and explanation:
[Unit] Description=Wicd sleep hook Before=sleep.target StopWhenUnneeded=yes [Service] Type=oneshot RemainAfterExit=yes ExecStart=-/usr/share/wicd/daemon/suspend.py ExecStop=-/usr/share/wicd/daemon/autoconnect.py [Install] WantedBy=sleep.target
RemainAfterExit=yes: After started, the service is considered active until it is explicitly stopped.
StopWhenUnneeded=yes: When active, the service will be stopped if no other active service requires it. In this specific example, it will be stopped after sleep.target is stopped.
- Because sleep.target is pulled in by suspend.target, hibernate.target and hybrid-sleep.target and sleep.target itself is a StopWhenUnneeded service, the hook is guaranteed to start/stop properly for different tasks.
Hooks in /usr/lib/systemd/system-sleep
systemd runs all executables in
/usr/lib/systemd/system-sleep/, passing two arguments to each of them:
- Argument 1: either
post, depending on whether the machine is going to sleep or waking up
- Argument 2:
hybrid-sleep, depending on which is being invoked
In contrast to pm-utils, systemd will run these scripts concurrently and not one after another.
The output of any custom script will be logged by systemd-suspend.service, systemd-hibernate.service or systemd-hybrid-sleep.service. You can see its output in systemd's journal:
# journalctl -b -u systemd-suspend
An example of a custom sleep script:
#!/bin/sh case $1/$2 in pre/*) echo "Going to $2..." ;; post/*) echo "Waking up from $2..." ;; esac
Do not forget to make your script executable:
# chmod a+x /usr/lib/systemd/system-sleep/example.sh
man 7 systemd.special and
man 8 systemd-sleep for more details.
Enable RC6 Power Save Options
- 1: enable rc6
- 3: enable rc6 and deep rc6
- 5: enable rc6 and deepest rc6
- 7: enable rc6, deep and deepest rc6
Connection problems with Atheros AR9485 Wireless Network Adapter
You may experience connection problems with the Atheros AR9485 Wireless Network Adapter, which is caused by incorrect power management functioning. You can notice the problem if you're experiencing random disconnections in IM or other software that keeps connection alive for a long time. In case you're using laptop, first you must disable battery power-over-perfomance feature: Settings / Power Manager / On Battery / Prefer power savings over perfomance
Next thing to do is switch off power management for adapter: You should add
iwconfig wlan0 power off(assuming wlan0 is your AR9485 adapter) anywhere it can be executed on system init (or simply run it once, to fix the problem for current session) and that should do it.