Hi,

While researching how to get my laptop to save a bit more power in battery mode
I found a great hint at
http://www.neowin.net/forum/topic/1106745-howto-powersaving-tweaks-with-a-udev-rule/
which will fit nicely into LFS section 7.4 .

The idea is to create a udev rules file like this...

cat > /etc/udev/rules.d/60-powersave.rules << "EOF"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/sbin/powersave true" SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/sbin/powersave false"
EOF

...and then a powersave script. This will be called every time the power supply is connected or disconnected.

cat > /usr/sbin/powersave << "EOF"
#!/bin/sh
case "$1" in
true) # Enable power saving settings on battery
#
# Device Runtime-PM
for dpcontrol in /sys/bus/{pci,spi,i2c}/devices/*/power/control; do echo auto > $dpcontrol; done
#
# Disable nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
#
# kernel write mode
echo 5 > /proc/sys/vm/laptop_mode
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
#
# disk powersave
hdparm -B 127 /dev/sda &> /dev/null
# for i in /sys/class/scsi_host/host*/link_power_management_policy; do echo min_power > $i; done
#
# sound card powersave
# echo 10 > /sys/module/snd_hda_intel/parameters/power_save
# echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
#
# wlan0 powersave
# iwconfig wlan0 power on &> /dev/null
#
# cpufreq powersave
echo powersave > /sys/bus/cpu/devices/cpu0/cpufreq/scaling_governor
;;
false) # Return to default on AC power
#
# Device Runtime-PM
for dpcontrol in /sys/bus/{pci,spi,i2c}/devices/*/power/control; do echo on > $dpcontrol; done
#
# Enable nmi_watchdog
# echo 1 > /proc/sys/kernel/nmi_watchdog
#
# kernel write mode
echo 0 > /proc/sys/vm/laptop_mode
echo 500 > /proc/sys/vm/dirty_writeback_centisecs
#
# disk powersave
hdparm -B 254 /dev/sda &> /dev/null
# for i in /sys/class/scsi_host/host*/link_power_management_policy; do echo max_performance > $i; done
#
# sound card powersave
# echo 300 > /sys/module/snd_hda_intel/parameters/power_save
# echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
#
# wlan0 powersave
# iwconfig wlan0 power off &> /dev/null
#
# cpufreq ondemand
echo ondemand > /sys/bus/cpu/devices/cpu0/cpufreq/scaling_governor
;;
esac
exit 0
EOF

I've made a few changes to the original script and commented out some other commands to suit my computer configuration and my preferences, other users will want to adjust
the file to their own needs.

A more detailed explanation can be found in the link above and in this archlinux forum topic.
https://bbs.archlinux.org/viewtopic.php?id=148210

Regards,
Ed Batalha
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://en.wikipedia.org/wiki/Posting_style

Reply via email to