You are not logged in.
Pages: 1
I've written a short bash script that throws up a zenity requester to enable choosing a cpu frequency and then setting it in /etc/conf.d/cpufreq and restarting cpufreq. The zenity requester is very straightforward, offering 5 frequencies, and the choice is stored in a bash variable $freq. The script then uses sed to replace the max_freq in cpufreq config file. However, whilst I have this working I'm sure there must be a better way. The line for changing is:
max_freq="X.XGhz"
Including quotes. This creates a problem because to get the $freq into the sed expression I have to double quote the whole thing. I'm currently using
eval "sed -i -e 's/\(max\_freq\=.\).*\(.Hz.\)/\1$freq\2/g' /etc/conf.d/cpufreq"
I'm sure that there must be a better way of doing this, though, if anyone has any ideas?
Incidentally, it's necessary because I often have to run my processor at 100% for extended periods, and during the hot weather this can lead to overheating, so it's handy to have a simple method of underclocking my CPU during these periods.
Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703
/ is the root of all problems.
Online
First, I'm not sure why the eval is there. Unless there is some need I am not understanding, I'd recommended dropping it. Then the sed line could be
sed -i 's/\(max_freq="\)[0-9\.]*/\1'$freq'/' /etc/conf.d/cpufreq
Last edited by Trilby (2012-05-28 10:45:18)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I never thought of un-quoting $freq in the sed line Doh!
The eval was there because it seemed to be the only way that I could get $freq converted.
Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703
/ is the root of all problems.
Online
Pages: 1