[Bin] Add CPU scaling script

This commit is contained in:
Lucien Cartier-Tilet 2022-04-11 14:50:05 +02:00
parent d41fc9c3ca
commit f29e48ed37
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -187,6 +187,25 @@ source code here:
cp -r $argv[1] $argv[1].bak.(date +"%Y%m%d%H%M%S") cp -r $argv[1] $argv[1].bak.(date +"%Y%m%d%H%M%S")
#+END_SRC #+END_SRC
** CPU Scaling
:PROPERTIES:
:HEADER-ARGS: :shebang "#!/usr/bin/env bash" :mkdirp yes :tangle ~/.local/bin/cpu-scaling
:CUSTOM_ID: cli-utilities-CPU-Scaling-f64iyk608fj0
:END:
As I am using a laptop, maximum performance isnt always what I want.
Sometimes, its just better to have not so great but less
battery-demanding performance. It is possible to achieve this by
modifying the CPU governor with ~cpupower~. The [[https://wiki.archlinux.org/title/CPU_frequency_scaling#Scaling_governors][Arch Wiki]] has, as usual,
some really good documentation on this.
The following script asks the user through ~rofi~ which governor to
apply, and it relies on [[#Askpass-d0d7a8c0][~askpass~]] to retrieve the users password.
#+begin_src bash
governors=("performance" "powersave" "userspace" "ondemand" "conservative" "schedutil")
governor=$(printf "%s\n" "${governors[@]}" | rofi -dmenu)
sudo -A cpupower frequency-set -g "$governor"
#+end_src
** Development ** Development
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: cli-utilities-Development-baec808a :CUSTOM_ID: cli-utilities-Development-baec808a