You are not logged in.
Hi ![]()
I want to change the CPU frequency between powersave, ondemand and performance profils with shortcuts without enter my password. I want to change the frequency depending of my laptop is running on battery or is plugged ; Or depending my laptop's battery level.
I tried to make shortcuts and added exceptions with "NOPASSWD" in /etc/sudoers file but it doesn't work.
I tried 2 methods :
1) /etc/sudoers :
user ALL=(ALL) ALL
user ALL=(ALL) NOPASSWD: /usr/bin/sudo /usr/bin/cpupower frequency-set -g performance
2) I made a script named "cpupower-p" which contains :
"sudo cpupower frequency-set -g performance"
/etc/sudoers :
user ALL=(ALL) ALL
user ALL=(ALL) NOPASSWD: /usr/bin/sudo /home/user/cpupower-p
Every time I launched the command in the terminal, it asks me my password. When I tap the shortcut nothing happen and when I not write "sudo", it tells me :
"Subcommand frequency-set needs root privileges"
For now the only solutions I have to change the frequency without password are:
- Change it with cpupower-gui, that's what I use now.
- Disable the password's demands with "user ALL=(ALL) NOPASSWD: ALL" but I don't want to do that. I just want an exception for the CPU frequency.
If you can help me, I'll appreciate it. ![]()
Last edited by Niram96 (2022-07-28 19:52:12)
* * * * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * * * * * * *
Offline
Hi,
your entries in the sudoers file should not include /usr/bin/sudo but just the command that is called via sudo, i.e.:
user ALL=(ALL) NOPASSWD: /usr/bin/cpupower frequency-set -g performance
user ALL=(ALL) NOPASSWD: /home/user/cpupower-pOffline
Hi,
Lol I don't understand, I previously tried without sudo and it didn't work. ![]()
I probably used a wrong command.
Thank you ! It works fine now. ![]()
* * * * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * * * * * * *
Offline