Difference between revisions of "Power saving"

From ArchWiki
Jump to: navigation, search
(Configuration: merged to Power management#Power saving)
(Tools and scripts: merged to Power management)
Line 11: Line 11:
  
 
This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to [[Wikipedia:Intel Turbo Boost|dynamic overclocking]].
 
This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to [[Wikipedia:Intel Turbo Boost|dynamic overclocking]].
 
== Tools and scripts ==
 
 
=== Using a script and an udev rule ===
 
 
Since systemd users can suspend and hibernate through {{ic|systemctl suspend}} or {{ic|systemctl hibernate}} and handle acpi events with {{ic|/etc/systemd/logind.conf}}, it might be interesting to remove [[pm-utils]] and [[acpid]]. There is just one thing systemd cannot do (as of systemd-204): power management depending on whether the system is running on AC or battery. To fill this gap, you can create a single [[udev]] rule that runs a script when the AC adapter is plugged and unplugged:
 
 
{{hc|/etc/udev/rules.d/powersave.rules|2=<nowiki>
 
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/path/to/your/script true"
 
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/path/to/your/script false"
 
</nowiki>}}
 
 
{{Note|You can use the same script that ''pm-powersave'' uses. You just have to make it executable and place it somewhere else (for example {{ic|/usr/local/bin/}}).}}
 
 
Examples of powersave scripts can be found here: [[powerdown]], [https://github.com/Unia/powersave powersave].
 
 
The above udev rule should work as expected, but if your power settings are not updated after a suspend or hibernate cycle, you should add a script in {{ic|/usr/lib/systemd/system-sleep/}} with the following contents:
 
 
{{hc|/usr/lib/systemd/system-sleep/00powersave|<nowiki>
 
#!/bin/sh
 
 
case $1 in
 
    pre) /path/to/your/script false ;;
 
    post)     
 
if cat /sys/class/power_supply/AC0/online | grep 0 > /dev/null 2>&1
 
then
 
    /path/to/your/script true
 
else
 
    /path/to/your/script false
 
fi
 
    ;;
 
esac
 
exit 0
 
</nowiki>}}
 
 
Do not forget to make it executable!
 
 
{{Note|Be aware that AC0 may be different for your laptop, change it if that is the case.}}
 
 
Now you do not need pm-utils anymore. Depending on your configuration, it may be a dependency of some other package. If you wish to remove it anyway, run {{ic|pacman -Rdd pm-utils}}.
 
 
=== Print power settings ===
 
 
This script prints power settings and a variety of other properties for USB and PCI devices.  Note that root permissions are needed to see all settings.
 
 
{{bc|<nowiki>
 
#!/bin/bash
 
 
for i in $(find /sys/devices -name "bMaxPower")
 
do
 
busdir=${i%/*}
 
busnum=$(<$busdir/busnum)
 
devnum=$(<$busdir/devnum)
 
title=$(lsusb -s $busnum:$devnum)
 
 
printf "\n\n+++ %s\n  -%s\n" "$title" "$busdir"
 
 
for ff in $(find $busdir/power -type f ! -empty 2>/dev/null)
 
do
 
v=$(cat $ff 2>/dev/null|tr -d "\n")
 
[[ ${#v} -gt 0 ]] && echo -e " ${ff##*/}=$v";
 
v=;
 
done | sort -g;
 
done;
 
 
printf "\n\n\n+++ %s\n" "Kernel Modules"
 
for mod in $(lspci -k | sed -n '/in use:/s,^.*: ,,p' | sort -u)
 
do
 
echo "+ $mod";
 
systool -v -m $mod 2> /dev/null | sed -n "/Parameters:/,/^$/p";
 
done
 
</nowiki>}}
 
  
 
== See also ==
 
== See also ==

Revision as of 12:24, 23 April 2015

This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to dynamic overclocking.

See also