New Script to deactivate Nap ?

Since the new version of the chud tools, my script to deactivate the nap-mode of the processor doesn’t work anymore.
The PreferencePane changed as well. It’s now called “Processor” and it moved from OTHERS to HARDWARE.

The old script:
do shell script “hwprefs cpu_nap=false”

doesn’t work anymore.

How to change it to make it work again ?

The only way I could find is to do it as Administrator - this means plaintext password in the script:

do shell script "hwprefs cpu_nap=false" user name "shortname" password "myPassword" with administrator privileges

I’d like to know if there is any other way.

Awesome…

For me this is Okay, as I’m the only one on my computer and nobody would ever see the password.
With little snitch installed the Script won’t send anything out to the internet as well.

So, this is good for me. Thank you very much !

Anyway, if there is another possibility I would still be interested.

Bye
Timo

Well now this is interesting - I opened the package of the Preference Pane, which is in /System/Library for some reason, and the executable in there won’t run. So I did BSD “find” for “hwprefs*” and the only one I find is in the directory /usr/bin/ .

The permissions on /usr/bin are drwxr-xr-x 737 root wheel, so all users should be able to execute.

Now when I try to run my script, I no longer need the Admin authorization.

I have no idea why. I’ll see what it does after the next logout in case it is a sudo issue.

Hi.

I’d like to also turn off the second processor and set the processor performance to reduced (in energy saver). Or better yet: a toggle of them. So when everythings off and on low, then it’d turn everything on and on high, and vice-versa… is that possible?

kind regards,
oddy

You can do it, but you need the “hwprefs” command-line utility installed. You can get this by installing the CHUD tools that are located in the Developer Tools, under the Performance directory.

To disable one processor,


do shell script "hwprefs cpu_count=1" user name "shortname" password "myPassword" with administrator privileges

and to reenable it


do shell script "hwprefs cpu_count=2" user name "shortname" password "myPassword" with administrator privileges

Also to set the processors to energy saving,


do shell script "sudo pmset -a reduce 1" user name "shortname" password "myPassword" with administrator privileges

and to reset to non-reduced power,


do shell script "sudo pmset -a reduce 0" user name "shortname" password "myPassword" with administrator privileges

To retrieve the reduced-power setting, use


do shell script "sudo pmset -g | grep -m1 reduce | awk '{print $2}'" user name "shortname" password "myPassword" with administrator privileges

then you can assign it to a variable and use that to set the power setting to make it a toggle.


set reduced to (do shell script "sudo pmset -g | grep -m1 reduce | awk '{print $2}'" user name "shortname" password "myPassword" with administrator privileges) as integer

set powerSetting to (((reduced is not 1) as integer) as string)
set procs to (reduced + 1) as string

do shell script "sudo pmset -a reduce " & powerSetting user name "shortname" password "myPassword" with administrator privileges

do shell script "hwprefs cpu_count=" & procs user name "shortname" password "myPassword" with administrator privileges

That will read the “reduced power” setting, and if it is reduced, it will (set it to not reduced, and set the processors to 2). If it is not reduced, it will (set it to reduced and set the processors to 1).