Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to set CPU processing speed System
After wanting this for years, I finally looked at the AppleScript menu icon, and was driven to find out how to do this myself. Time to give back a tip when I've used so many...

Many times, I'll want to change my CPU speed on my notebook to suit my current work, especially when running on battery. Web browsing is not very CPU intensive, while playing games usually is. So I've created an AppleScript to switch to the "Highest" CPU setting. Actually, I have three settings -- Reduced, Highest and Automatic. GUI Scripting must be enabled.

[robg adds: This script works as described. To make three versions, you'll want to change two lines:
click menu item "Highest" of menu "OtherViews" of pop up button 1
and
display dialog "CPU Speed set to Highest" buttons {"Ok"} giving up after 2
Change Highest in the first line to either Automatic or Reduced, and then change the message in the last line to reflect that choice. Save the modified script with a new name. To make the scripts easy to get at, save them in your user's Library: Application Support: Scripts folder. They'll now appear under the Script icon in the menubar (which can be enabled in the Applications: AppleScript folder).]
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (5 votes cast)
 
[16,301 views]  

A script to set CPU processing speed | 17 comments | Create New Account
Click here to return to the 'A script to set CPU processing speed' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to set CPU processing speed
Authored by: stewby on Mar 03, '05 11:03:31AM
You could also write a script that uses the terminal command pmset (see man pmset and/or some of the comments in this hint) to change those settings.

[ Reply to This | # ]
A script to set CPU processing speed
Authored by: Azark on Mar 03, '05 12:21:36PM
I made a few pmset shell scripts in OnMyCommand for that purpose. Not only CPU, but dim screen, etc.

You just have to add pmset to the sudoers file to be able to use it without password, tip here.

Typing 'pmset' alone in terminal will give you an easy view of its usage.

A few examples:

CPU:
High: sudo /usr/bin/pmset -c reduce 1
Low: sudo /usr/bin/pmset -c reduce 0
Auto: sudo /usr/bin/pmset -c reduce 0 dps 1

Sleep:
sudo /usr/bin/pmset -c sleep 10

-c means "connected to charger" you can change it to -b (battery), -u (UPS), -a (all)

---
iMac G5 1GB SD 10.3.7 /
G4 400 AGP 768MB 10.3.7 /
G4 400 AGP 768MB OSX Server 10.3.7

[ Reply to This | # ]

A script to set CPU processing speed
Authored by: billbarstad on Mar 03, '05 12:29:23PM

Or, just download iCooked and set your CPU speed from the menu bar.



[ Reply to This | # ]
A script to set CPU processing speed
Authored by: mfc2mfc2 on Mar 05, '05 01:48:04PM
The iCooked ReadMe file says that it works with IBM 750FX processors. So I guess my PowerBook G4 is out.

The CPUPerformance.menu file http://web.telia.com/~u60527006/ worked for me.

[ Reply to This | # ]
A script to set CPU processing speed
Authored by: TimBonnici on Mar 06, '05 06:09:21PM
For those who prefer a monochrome icon and a simpler menu I recommend FastAndSlow which works very nicely on my G4 PB. It's just a simple GUI wrapper for pmset.

[ Reply to This | # ]
A script to set CPU processing speed
Authored by: Anonymous on Mar 03, '05 03:16:16PM
I added some code to this applescript to give you a choice of "Highest" or "Reduced" in a dialog box. Which ever one you choose the applescript sets your CPU to the desired result.

global myCPU
set myCPU to ""
display dialog "What would you like?" buttons {"Highest","Reduced"}

copy the result as list to {button_pressed}
if button_pressed is "Highest" then
   set myCPU to "Highest"
else if button_pressed is "Reduced" then
   set myCPU to "Reduced"
end if

tell app "System Preferences"
activate
  set current pane to pane "com.apple.preference.energysaver"
  tell app "System Events"
        get properties
        tell process "System Preferences"
          tell window "Energy Saver"
            tell group 1
             tell tab group 1
               click radio button "Options"
               click pop up button 1
             click menu item myCPU of menu "OtherViews" of pop up button 1
               try
                  click button "Click the lock to make changes" of window 
                   "Network" of process "System Preferences" of 
                      application "System Events"
               end try
              end tell
             end tell
            end tell
           end tell
          end tell
end tell

ignoring application responses
      tell app "System Preferences" to quit
display dialog "CPU Speed set to " & myCPU giving up after 2
end ignoring
I also did something just like this to set my sound to the left, right, or center.

[ Reply to This | # ]
A script to set CPU processing speed
Authored by: gapns on Mar 05, '05 09:06:01AM
When I tried to use this script on my iMac G5, I had to change the tab group from 1 back to 0

				tell group 0
					tell tab group 0

otherwise it works well.
Thanks

[ Reply to This | # ]
A script to set CPU processing speed
Authored by: GlowingApple on Mar 07, '05 01:42:17PM

When I try to run this script I get an error on the line "ignoring application responses". The error is "Expected end of line, etc. but found end of script." If I comment the line out it compiles. Then when I run it again I get an error on the line "click menu item myCPU of menu "OtherViews" of pop up button 1" The error here is "System Events got an error: NSReceiverEvaluationScriptError: 4" I have a feeling this has something to do with the fact that my panels are all locked. I see the try statement to try to unlock them, but it seems it does not work. I don't know too much about GUI scripting, so I'm not sure what I'd need to change. Any ideas?

Thanks!

---
Jayson

When Microsoft asks you, "Where do you want to go today?" tell them "Apple."



[ Reply to This | # ]
A script to set CPU processing speed
Authored by: jzdziarski on Mar 03, '05 03:51:46PM

There's also a great little menu app here: http://web.telia.com/~u60527006/
designed specifically to set the CPU levels for both ac and battery.



[ Reply to This | # ]
A script to set CPU processing speed
Authored by: rgray on Mar 03, '05 04:38:09PM
There's also a great little menu app here: http://web.telia.com/~u60527006/ designed specifically to set the CPU levels for both ac and battery.

Which file in particular???

Index of /~u60527006
cpuPerformance-0.3b...> 25-Nov-2004 19:29 16k
cpuPerformance-0.4b...> 25-Nov-2004 19:29 17k
cpuPerformance-0.6.1..> 25-Nov-2004 19:29 14k
cpuPerformance.menu.tbz 25-Nov-2004 19:29 13k
cpuPerformance.menu.zip 25-Nov-2004 19:29 16k
dk.jpg 25-Nov-2004 19:29 2k
logoutMenuExtra.menu..> 25-Nov-2004 19:29 11k
pipeline.png 25-Nov-2004 19:29 273k
sample.jpg 25-Nov-2004 19:29 16k
sample.png 25-Nov-2004 19:29 44k
sample2.png 25-Nov-2004 19:29 32k
vpc.png 25-Nov-2004 19:29 489k



[ Reply to This | # ]

A script to set CPU processing speed
Authored by: jzdziarski on Mar 03, '05 06:01:09PM

which one do you think?



[ Reply to This | # ]
A script to set CPU processing speed
Authored by: Brad Puett on Mar 03, '05 11:27:57PM
which one do you think?
... I don't know ... maybe dk.jpg ??!

Instead of a(nother) sarcastic response, how about just telling us and then we'll ALL know!!

(BTW, I would have thought cpuPerformance-0.6.1b and cpuPerformance would have pointed to the same file, but since they each have a different size ... ; of course, I would have also thought cpuPerformance-0.3b, cpuPerformance-0.4b and cpuPerformance-0.6.1b would have different last modified dates from each other, but since they don't ... )



[ Reply to This | # ]
A script to set CPU processing speed
Authored by: rgray on Mar 04, '05 08:27:39AM
Thank you, Brad. I restrained myself from jumping on this when I first saw it last night (sober second thought and all...). Five files all with the same date. We all know how important versions can be and that latest isn't always best.
    If one is going to give a link, why not
  • 1. make it accurate,
  • 2. make it a proper clickable link,
  • 3. make it point to the the actual author's site instead of blythly pumping up versiontracker (etc.) counts.

When one gets a sarcastic response such as that above, one is inevitably led to suspect that its author does not actually know! Blowing smoke just wastes everybody's time.

I haven't had a moment to follow up here testing the various versions so I still don't know.....

I thought the ethos here was to be helpful.... 'nuff said.

[ Reply to This | # ]

A script to set CPU processing speed
Authored by: sjonke on Mar 04, '05 09:02:39AM

Who do you think is an ass?

---
--- What?



[ Reply to This | # ]
A script to set CPU processing speed
Authored by: raider on Mar 07, '05 02:14:30PM
OK, since no-one is really explaining this to anyone, and the purpose of this site is to HELP people, I figured I would explain what I found here:

OK. I downloaded both
cpuPerformance-0.6.1..> 25-Nov-2004 19:29 14k
cpuPerformance.menu.zip 25-Nov-2004 19:29 16k


I found that the 0.6.1 version, after unzipping, had the latest file date.

The way you "install" the menu item is to double click on the .menu file. It will add it. But you want to make sure that you have it in the place that you want it to reside before you install it.

I chose
/Library/Menu Extras/
as the place I put mine.

It works as advertised, however the change won't be "visible" if you have System Prefs open at the time. But if you close and reopen System Prefs the change shows up. The icon of the 0.6.1 version is not the same as the one in the screenshots, but a monotone version that better fits in the menubar.

To uninstall, you simply hold Command and drag it off the menu bar. Then you will want to delete the .menu file. I found that I had to log out and log back in before I could delete the menu file, as it kept claiming it was in use - even though there was no process using it... (strange).

I also found that if I command dragged it off the menu bar and then re-added it, the icon didn't show up. If I logged out and back in, and added it then the icon showed up. I am not sure if it is flaky, or just the add/remove from the menu bar that is being flaky.

And finally - this is all YOUR RISK. I have no idea who wrote this utility, or what it is behind the scenes. Little Snitch hasn't reported any strange activity, and I haven't seen any adverse effects. But there is very little accountability in this as they are simply files on a server.

USE AT YOUR OWN RISK
YOUR MILEAGE MAY VARY
BATTERIES NOT INCLUDED
IF USED IMPROPERLY SEVERE INJURY AND/OR DEATH COULD OCCUR

:)

[ Reply to This | # ]
A script to set CPU processing speed
Authored by: rgray on Mar 08, '05 09:27:06AM
Thank you, raider, for the real help. I just finished similar research with a similkar conclusion, and came back to post only to find you'd beaten me to it...... No need for me to post my findings - they are the same.

[ Reply to This | # ]
Other pre-launch game things for Applescript to do
Authored by: broaddd on Mar 21, '05 10:02:55PM

On a similar note, I was thinking of doing some 'folder action' Applescripts for my games folders.

For example, when I double click on my Halo folder, I'd like the Applescript to:
- open Toast, mount my Halo disc image (I prefer not to mount physical discs for games, aren't serial numbers enough?), quit Toast
- open System Preferences, set the processor speed to 'highest', quit system preferences
- quit all open applications
- maybe adjust the sound volume from the usual quiet to mid-level
- maybe switch the function key settings, so I can use them in games without holding down the 'fn' key.
- launch the game
- on my quit of the game, revert processor speed to 'automatic', eject disc image, adjust volume, adjust function keys etc.

I thought someone may have done something similar, and I would appreciate any tips, as I am a total newbie to Applescript.

Cheers,
B



[ Reply to This | # ]