Provide a custom power management setting in GNOME Control Center for extreme energy savings on battery
Open, Needs TriagePublic

Description

Maybe a bit crazy but could interest some users who want extremely long battery life in exchange for lesser performance... this worked back when I was using a Sandybridge-based X220, but not on an Ironlake-based X201 (made no difference). It's two scripts, to be toggled when you enter/exit battery mode:

#!/bin/bash
# Put all CPUs in powersave mode, turn off everything except CPU 0
for i in /sys/devices/system/cpu/cpu?/; do
#    echo powersave > "$i/cpufreq/scaling_governor"
    # If not CPU 0:
    if [[ ${i:$((-2))} != "0/" ]]; then
        echo 0 > "$i/online"
    fi
done

Jeff: I remember matthew garrett arguing that you should never set the governor to something other than ondemand; that if you downclock/limit your CPU, you spend more time doing the work and so end up eating more power overall
n.: Yes, that's if you're using the CPU. It depends on your workload, and in my experience, the typical hacking workload (90% time in vim, 10% time compiling [unless you're hacking on webkit, hah!]) means powersave saves power. And while you do that, processes in the background are happily causing CPU spikes, and causing the ondemand governor to spike the CPU frequency

And the 2nd part, the script when you come back into "plugged in mode":

#!/bin/bash
# Put all CPUs out of powersave mode, turn on everything
for i in /sys/devices/system/cpu/cpu?/; do
#    if [[ ${i:$((-2))} != "0/" ]]; then
        echo 1 > "$i/online"
#    fi
#    echo ondemand > "$i/cpufreq/scaling_governor"
done

If we want to offer 15-20 hours battery life as an opt-in (not impossible I think, would need to be tested though) then this could be provided as an option in the gnome control center's Energy settings.

Add Comment