mercredi 31 octobre 2012

powertop2 : make power saving changes persistent with a linux shell script


Based on ideas seen in archlinux forums, this will run powertop2, parse its report and extract commands into a shellscript/config file, you can run it, or put it in a boot time service to enforce settings.

luser@x60s_GPT ~ (master*) % uname -a
Linux x60s_GPT 3.6.4-1-ARCH #1 SMP PREEMPT Mon Oct 29 15:13:56 CET 2012 i686 GNU/Linux


luser@x60s_GPT ~ (master*) % cat powertop.config.sh
#!/usr/bin/env dash
PREFIX="powertop.$(date '+%d%b%g-%H:%M:%S')"
HTMLNAME="${PREFIX}.html"
CONFNAME="${PREFIX}.conf"
POWERTOP=$(which powertop)

echo "running ${POWERTOP}"
sudo ${POWERTOP} --html=${HTMLNAME}
echo "report -> commands -> ${CONFNAME}"
cat  ${HTMLNAME} | sed 's,<,\n<,g' | sed -ne '/echo/ s,^.*\(echo.*\);.*$,\1,gp' | tee ${CONFNAME} | less