Saturday, 18 June 2011

PowerTop - Howto Enable Device Power Management by pressing the P key

Have you ever ran powertop? If not, have a look at these links.



When you run powertop as root (eg. sudo powertop), it might recommend something like this: 
Enable Device Power Management by pressing the P key
 
 
So how do you do this when powertop is not running?
 
This forum made a suggestion that I have attempted to simplify.
find /sys/devices/pci* -path "*power/control" -exec bash -c "echo auto > '{}'" \;

Or you can use this slightly longer one that echo's values before and after it changes.
find /sys/devices/pci* -path "*power/control" -exec \
  bash -c "echo -n '{}' = && cat '{}' && echo auto > '{}' && echo -n '{}' = && cat '{}'" \;

Both have to be run as root or using sudo.
eg.
sudo find /sys/devices/pci* -path "*power/control" -exec bash -c "echo auto > '{}'" \; 
 
Here is my bash script that I run with an extra powertop recommendation that may 
not be applicable in your case.
 
#!/bin/bash

find /sys/devices/pci* -path "*power/control" -exec \
  bash -c "echo -n '{}' = && cat '{}' && echo auto > '{}' && echo -n '{}' = && cat '{}'" \;

F="/sys/module/snd_hda_intel/parameters/power_save"
echo -n $F = && cat $F
echo 1 > $F
echo -n $F = && cat $F