CPU Frequency scaling

advice wanted

Is there a good program that you use to set CPU frequency when playing games ?

Currently I have a script that changes the CPU frequency from power-saving to performance but it requires root privileges and its annoying entering my password each time.

Posted Jul 17, 2021, 9:42 AM UTC

85
KPatrik•

Check out feral gamemode it does that for you. https://github.com/FeralInteractive/gamemode use it for all my games and it works great :)

8
ungilOP•

Thank you very much

1
grandmastermoth•

Depending on your distro you may find Gamemode already installable in the repositories.

1
Scill77•

On desktop I use 'performance' mode by default, on laptop i use "conservative".

Use cpufrequtils utility for desktop or tlp one for laptops.

2
hpsu_•

You could use a script like this:

#!/bin/bash


current=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)

if [ $current == "powersave" ]; then
	echo performance | sudo /usr/bin/tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor && notify-send 'Performance' -a 'CPU Governor' -i cpu
else
	echo powersave | sudo /usr/bin/tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor && notify-send 'Powersave' -a 'CPU Governor' -i cpu
fi

And add a file to sudoers.d, i.e /etc/sudoers.d/cpufreq containing:

ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

That way you should be able to edit freq with sudo without entering a password.

2