You are not logged in.

#1 2020-01-22 10:30:34

scippie
Member
Registered: 2019-06-07
Posts: 127

[SOLVED] Manage cpu power without root privileges

Not sure if I should ask it in this forum, but I don't think it's a 'newbie' question so... Please correct me if I am mistaken.

I have an intel i9 5Ghz CPU on my new machine (laptop). This kind of power is seldomly needed and, especially when running badly written software will make my fans go wild because it doesn't idle and things like that.
When I am playing Kingdom Two Crowns, it runs perfectly on 1.5Ghz without spinning up the fans, but if I give it 5Ghz, it will run exactly as smooth but my fan goes wild and CPU goes up to 90 degrees C.
When I want to play X4, I want the full 5Ghz to be available and I don't care about the fans.
Until now, I have been using cpupower(-gui) to control this, but it's not handy because you need root-privileges to use it. I want to be able to control it easier.

Is it possible to give my user the rights to use cpupower to set the upper frequency so that it no longer needs a password?
I have looked at the files like /sys/devices/system/cpu/cpu0/cpufreq/scaling_set_speed to see if I could add my user to that group but it's root.

I would then love to create an i3blocks script that shows the current upper frequency and is able to change it with the scroll wheel. But I don't think that's possible when it needs root privileges to do so.

Edit: This is solved. For those who are interested in my i3blocks script: https://github.com/scippie75/arch_bto_1 … pts/cpu.py

Last edited by scippie (2020-01-24 12:47:40)

Offline

#2 2020-01-22 10:55:25

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED] Manage cpu power without root privileges

https://wiki.archlinux.org/index.php/CPU_frequency_scaling#cpupower-gui wrote:

The application handles privilege granting through polkit and allows any logged-in user in the wheel user group to change the frequency and governor.

If you prefer a fine-grained approach to privileges, check the polkit page or use /etc/sudoers .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2020-01-22 11:42:39

scippie
Member
Registered: 2019-06-07
Posts: 127

Re: [SOLVED] Manage cpu power without root privileges

Lone_Wolf wrote:
https://wiki.archlinux.org/index.php/CPU_frequency_scaling#cpupower-gui wrote:

The application handles privilege granting through polkit and allows any logged-in user in the wheel user group to change the frequency and governor.

I agree and I admit that I overlooked it (still a noob after all).
But that's for cpupower-gui unless I am missing something.
Is there a way to do it for cpupower, the non-gui version so I can call it from a script?

Offline

#4 2020-01-22 11:55:36

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,415

Re: [SOLVED] Manage cpu power without root privileges

As mentioned you could adjust /etc/sudoers. You can configure sudoers to allow certain programs and arguments to be executed without a password, so you can run them with sudo without specifying a password. https://wiki.archlinux.org/index.php/Su … le_entries

Offline

#5 2020-01-22 11:57:47

scippie
Member
Registered: 2019-06-07
Posts: 127

Re: [SOLVED] Manage cpu power without root privileges

V1del wrote:

As mentioned you could adjust /etc/sudoers. You can configure sudoers to allow certain programs and arguments to be executed without a password, so you can run them with sudo without specifying a password. https://wiki.archlinux.org/index.php/Su … le_entries

You are right. I am sorry. I have been using/configuring sudoers for many years now but never on that level so I never though about looking into it further.

Edit: got it to work, thanks!

Last edited by scippie (2020-01-22 12:06:59)

Offline

#6 2020-01-24 12:48:38

scippie
Member
Registered: 2019-06-07
Posts: 127

Re: [SOLVED] Manage cpu power without root privileges

For those that are interested in my i3blocks script to see the CPU load-average and current CPU frequency, and want to be able to change that frequency with the scrollwheel or simple click to toggle between min/max, see: https://github.com/scippie75/arch_bto_1 … pts/cpu.py

Offline

Board footer

Powered by FluxBB