Well, if everything else fails, you can try udev rules. I’ll post mine here. Currently they are all commented because all is set in TLP and working perfectly. Just check compatibility of the commands (the “scripts”) with your hardware and uncomment the ones you want test. You need to reload the rules with udevadm
or reboot the system for them to work.
Udev rules:
[mbb@mbb-laptop ~]$ cat /etc/udev/rules.d/98-ACDC-behaviour.rules
# Set governor to powersave and disable turbo boost on DC (handled by tlp)
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/cpugov-powersave.sh"
# Set governor to performance and enable turbo boost on AC (handled by tlp)
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/cpugov-performance.sh"
# Set software energy policy hint to 10 on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/x86-energy-policy-power.sh"
# Set software energy policy hint to 4 on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/x86-energy-policy-performance.sh"
# Set gpu max frequency to 750 Mhz on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/set_gpu_frequency_power.sh"
# Set gpu frequencies to defaults on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/set_gpu_frequency_performance.sh"
# Set turbo boost off on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/set_turboboost_off.sh"
# Set turbo boost on on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/set_turboboost_on.sh"
# Set cpu max frequency to 1200 Mhz on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/set_cpu_frequency_power.sh"
# Set cpu frequencies to defaults on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/set_cpu_frequency_performance.sh"
cpugov scripts:
[mbb@mbb-laptop ~]$ cat .bin/cpugov-powersave.sh
#!/bin/bash
# Set cpu governor to powersave and disable turbo boost
cpupower frequency-set -g powersave
echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
[mbb@mbb-laptop ~]$ cat .bin/cpugov-performance.sh
#!/bin/bash
# Set cpu governor to performance and enable turbo boost
cpupower frequency-set -g performance
echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
x86-energy-policy scripts:
[mbb@mbb-laptop ~]$ cat .bin/x86-energy-policy-power.sh
#!/bin/bash
# Set software perfofrmance/power hint to 10 (16*2/3-1)
x86_energy_perf_policy 15
[mbb@mbb-laptop ~]$ cat .bin/x86-energy-policy-performance.sh
#!/bin/bash
# Set software perfofrmance/power hint to 4 (16*1/3-1)
x86_energy_perf_policy 6
gpu_frequency scripts:
[mbb@mbb-laptop ~]$ cat .bin/set_gpu_frequency_power.sh
#!/bin/bash
# Set gpu max frequency to 750 Mhz
intel_gpu_frequency --custom max=750
[mbb@mbb-laptop ~]$ cat .bin/set_gpu_frequency_performance.sh
#!/bin/bash
# Set gpu frequencies to defaults
intel_gpu_frequency --defaults
turboboost scripts:
[mbb@mbb-laptop ~]$ cat .bin/set_turboboost_off.sh
#!/bin/bash
# Set turbo boost off
echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
[mbb@mbb-laptop ~]$ cat .bin/set_turboboost_on.sh
#!/bin/bash
# Set turbo boost on
echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
cpu_frequency scripts:
[mbb@mbb-laptop ~]$ cat .bin/set_cpu_frequency_power.sh
#!/bin/bash
# Set cpu max frequency to 1200 Mhz
cpupower frequency-set -u 1200Mhz
[mbb@mbb-laptop ~]$ cat .bin/set_cpu_frequency_performance.sh
#!/bin/bash
# Set cpu max frequency to 2800 Mhz
cpupower frequency-set -u 2800Mhz
In my machine, if I disable turbo boost, the cpu still reaches the maximum frequency (I mean, the turbo frequency). My cpu has a maximum frequency of 1800Mhz and a turbo frequency of 2800Mhz. The only way to limit the frequency under battery is to use cpupower frequency-set
. As you can see, I limit it to 1200Mhz, since it is enough for needs on bat and increases battery life a lot.