But is it possible to automatically switch to powersave when on battery, and performance when a charger is connected? I'm surprised that this functionality isn't already implemented by default.
You can use acpid to manage acpi events such as connecting to AC adapter. /etc/acpi/hadler.sh can be configured to change cpu governor on acpi events.
#/etc/acpi/handler.sh ac_adapter) case "$2" in AC*) case "$4" in 00000000) echo "powersave" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ;; 00000001) echo "performance" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ;; esac ;; *) logger "ACPI action undefined: $2" ;; esac ;;
If you use tlp, you can set
on /etc/default/tlp to do the same.