That’s a fine app but it is not scriptable (AFAIK) - such as smc0.01.app
Periodically, I measure the CPU temperature with M. Bresink’s “Temperature meter” app to adjust the temp accordingly.
Machine load varies significantly (after playing 1 single song in iTunes or show in iPhoto, after being idle for 5 minutes) so I dislike Apple’s built-in Fan Control. Here’s the idea (ignore some debugging code):
global fApp --passW
tell application "Keychain Scripting" to tell current keychain to tell (some generic key ¬
whose name is "ApplescriptAllow") to set passW to password
set {centigrade, FanSpeed} to rRun(passW, true)
sayz("CPU " & centigrade & "ËšC -> " & "Fan " & FanSpeed & " rpm.")
return {centigrade, FanSpeed}
on rRun(passW, SelectFromMenu)
set centigrade to word 1 of my readBresinkTemp(passW) -- from "36 C" -> "36"
tell application "System Events" to set fApp to name of some application process whose frontmost is true
if not SelectFromMenu then
set FanSpeed to my speedQuery(centigrade)
else
set myChoices2 to {"Automatic", "1500", "2000", "2500", "3000", "3500", "4000", "5500"}
tell application fApp to activate
beep
tell application fApp to set myResult to display better dialog ¬
" Specify new fan speed (rpm):" fields ¬
{{kind:popup menu, name:" ", field menu items:myChoices2}} ¬
buttons {"OK", "Cancel"} default button 1
set FanSpeed to field value of item 1 of fields returned of myResult
end if
if FanSpeed = "Automatic" then set FanSpeed to my speedQuery(centigrade)
-- dat werkt zonder password dialoog -> tell application "smc server" to rRun(FanSpeed, passW)
my setFanSpeed(FanSpeed, passW)
return {centigrade, FanSpeed}
end rRun
on speedQuery(centigrade)
set tempSpeedVect to {{"34", "1500"}, {"51", "2000"}, {"56", "2500"}, {"59", "3000"}, {"64", "3500"}, {"67", "4500"}, {"70", "5500"}}
repeat with g in tempSpeedVect
if centigrade > g's item 1 then set FanSpeed to g's item 2
end repeat
return FanSpeed
end speedQuery
on sayz(x)
if "xxxscript" is in fApp then
say x
else
tell application "System Events" to set GrowlAct to true --"GrowlHelperApp" is in name of application processes
if GrowlAct then
my GrowlNotify("", x, true)
else
my QSfAppNotify("", x, true)
end if
end if
end sayz
on GrowlNotify(theString, salut, fAppIcon)
tell application "GrowlHelperApp"
set the allNotificationsList to ¬
{"Fan Adjust Notification", "Another Fan Adjust Notification"}
set the enabledNotificationsList to ¬
{"Copy Notification"}
register as application ¬
"Growl FanAdjust" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Script Editor"
notify with name ¬
"Fan Adjust Notification" title ¬
(salut as string) description ¬
(theString as string) application name "Fan Adjust"
end tell
end GrowlNotify
on QSfAppNotify(theString, salut, fAppIcon)
tell application "System Events"
if fAppIcon = true then set pathToApp to (application file of (process "Finder"))
set IconRes to POSIX path of pathToApp
set sudName to (name of startup disk)
end tell
set sudNum to number of characters of sudName
set a to (theString) as string
set b to salut
tell application "Quicksilver" to show notification b text a image name IconRes
end QSfAppNotify
on readBresinkTemp(passW)
tell application "Finder"
set ut to (((path to applications folder) as string) & "Utilities") as string
set t to every item in folder ut whose name contains "HardwareMonitor" and name does not contain "Lite"
set t to item 1 of t
set t to POSIX path of (t as string) & "/Contents/Resources/hwmonitor"
end tell --return t
set theCmd to (t & " -c ") as string --> or: " /Applications/Utilities/TemperatureMonitor.app/Contents/Resources/tempmonitor -c -a "
set theRes to do shell script theCmd --password passW with administrator privileges
set t to word -2 of paragraph 1 of theRes
try
set t2 to word -2 of paragraph 2 of theRes
if t2 > t then set t to t2
end try
return t
end readBresinkTemp
on readBresinkTempObs()
tell application "Finder"
set ut to (((path to applications folder) as string) & "Utilities") as string
set t to every item in folder ut whose name contains "Temperature" and name contains "Monitor"
set t to item 1 of t
set t to POSIX path of (t as string) & "/Contents/Resources/tempmonitor"
end tell --return t
set theCmd to t & " -c -a" --> "sudo /Applications/Utilities/TemperatureMonitor.app/Contents/Resources/tempmonitor -c -a "
do shell script "sudo " & theCmd password passW with administrator privileges
end readBresinkTempObs
on setFanSpeed(FanSpeed, passW) --from Fan Control script
tell application "Keychain Scripting" to tell current keychain to tell (some generic key ¬
whose name is "ApplescriptAllow") to set passW to password
set newp to "/applications/smc-0.01/smc -k"
do shell script newp & " \"FS! \" -w 0003" password passW with administrator privileges -- here ID dialog pops up !!
if FanSpeed = "1500" then -- (default)
set resuld to do shell script newp & "\"FS! \" -w 0000" password passW with administrator privileges -- was sudo
else if FanSpeed = "2000" then --2000
set resuld to do shell script newp & " F0Tg -w 1f40" password passW with administrator privileges
set resuld to do shell script newp & " F1Tg -w 1f40" password passW with administrator privileges
else if FanSpeed = "2500" then --2500
set resuld to do shell script newp & " F0Tg -w 2710" password passW with administrator privileges
set resuld to do shell script newp & " F1Tg -w 2710" password passW with administrator privileges
else if FanSpeed = "3000" then --3000
set resuld to do shell script newp & " F0Tg -w 2ee0" password passW with administrator privileges
set resuld to do shell script newp & " F1Tg -w 2ee0" password passW with administrator privileges
else if FanSpeed = "3500" then --3500
set resuld to do shell script newp & " F0Tg -w 36b0" password passW with administrator privileges
set resuld to do shell script newp & " F1Tg -w 36b0" password passW with administrator privileges
else if FanSpeed = "4500" then --4500
set resuld to do shell script newp & " F0Tg -w 3e80" password passW with administrator privileges
set resuld to do shell script newp & " F1Tg -w 3e80" password passW with administrator privileges
else if FanSpeed = "5500" then --5500
set resuld to do shell script newp & " F0Tg -w 55f0" password passW with administrator privileges
set resuld to do shell script newp & " F1Tg -w 55f0" password passW with administrator privileges
else if FanSpeed = "Other" then
tell application "smcFanControl" to activate
end if
end setFanSpeed