Suppress password dialog with shell scripts called from QuicKeys

I am trying to control the fan speed of my MacBook with the scriptable smc application
http://www.filefactory.com/file/3cc9d6/

using the shell script


set passw to "mypassword"
do shell script "  /applications/smc-0.01/smc -k \"FS! \" -w 0000" password passW with administrator privileges 

that is called periodically from QuicKeys (every 5 mins). This shell script must be run as admin to work. Therefore, the password is defined.
However, this (still) always causes a password dialog with a QuicKeys icon where I need to re-enter the same password.
How can I overcome that…?

  1. Why not get the app from the developer?

http://81.169.182.62/~eidac/software/page5/page5.html

  1. Why do you need to run this thing every 5 minutes? What are you doing?

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

I don’t really see the benefit of this. Set the minimum temp and let the machine take care of thermal monitoring.

Seriously.

There is an interest in better thermal monitoring - a tradeoff between silence and turbo-prop cooling.
You can see anywhere on the Apple discussions how badly Apple’s solution is perceived.
BTW solution to re-authentication issue is to define the passw as a QuicKey variable


tell application "QuicKeys" to set value of variable named "passW" to passW 

Apple Discussions is not a cornucopia of thermal engineering majors, dude. They’re mostly average users.

Set your fans to something that is not below spec (the GUI smcFanControl app will make sure you don’t) and let the machine handle thermal monitoring. It is far smarter than Apple Discussions posters.

The intellectual level needed to conclude that overheated machines do burn laps is present at primary schools, at those places, and wherever else.
The “dude” that you specifically refer to, has reached it a couple of days after those machines came out.
It’s only marketing and thermal geniuses that have sublimed their brains…until they fall back to earth to publish new firmware, call back batteries, replace motherboards etc. and pay millions of dollars for their attitude.

But that’s not corporate arrogance, let’s call it Thinking Different…