This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Two commands on one kdesu line

Tags: None
(comma "," separated)
User avatar
RGB
Registered Member
Posts
346
Karma
0
OS

Two commands on one kdesu line

Sun May 22, 2011 5:01 pm
The background: the "ondemand" cpu governor work perfectly on most situations BUT when I need to perform a demanding process for a long time. For example, doing a skype video conference with ondemand governor push the cpu temperature for my five years old laptop above 90 degrees while when using "powersave" governor (which scale down cpu frequency) do not pass 60 degrees.
Because kpowersave do not give any more the chance to control cpu governors, I'm now using a small scrip to call cpufreq-set and slow down both cores:
Code: Select all
#!/bin/sh
kdesu cpufreq-set -c 0 -g powersave 
kdesu cpufreq-set -c 1 -g powersave

And that's the problem: I cannot find a way to use only one kdesu command so I need to enter my root password twice.
Is there an easy alternative?
Thanks!


RGB, proud to be a member of KDE forums since 2008-Nov.
And proud to be a kde user since 1.1.2
User avatar
kubicle
Registered Member
Posts
20
Karma
0
There are many ways you could accomplish that, here are a few suggestions:

1. in this case, simply doing "kdesu cpufreq-set -c 0 -c 1 -g powersave" should probably work.

2. you could remove kdesu commands from the script (running just cpufreq-set) and run the script with kdesu (which means the whole script will run as root)

3. you can chain multiple commands with kdesu by (for example) invoking a shell to run them:
kdesu "sh -c 'command1 ; command2'"

These are not the only solutions, but any one of these should work, choose your poison.


Thinking Inside the Box
User avatar
RGB
Registered Member
Posts
346
Karma
0
OS

Re: Two commands on one kdesu line

Sun May 22, 2011 7:10 pm
Thanks for the hints! Funny fact is that I already tried option 2 without success (it gave me an error that was not possible to run the script, without any other hint... who knows what I did...), but now it is working, so problem solved!
About option 1, it seems cpufreq-set can only accept one parameter at a time: it displays an error that the parameter was sent twice and then do nothing.
But anyway, everything is perfect now: I have a small auto-hide panel with two buttons, one to slow down the processor and the other to return to "normality".
Thanks again!


RGB, proud to be a member of KDE forums since 2008-Nov.
And proud to be a kde user since 1.1.2
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS

Re: Two commands on one kdesu line

Sun May 22, 2011 7:24 pm
Yet another alternative is to use the -c option. Not sure if the command below works, but you get the idea:
Code: Select all
kdesu -c "cpufreq-set -c 0 -g powersave; cpufreq-set -c 1 -g powersave"


This way you can also use && to run the second command only if the first one succeeded. (Well, I guess you could do that with the other methods as well... but anyway!)


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]