|
|
#1 |
|
Registered User
Join Date: Sep 2008
Posts: 2
|
launch a program when idle, quit the program when not
Hello all,
I am trying to find a way to have a specific program launch when the machine becomes idle (not when it goes to sleep), and then quits or the process is killed once the machine is not idle anymore. After looking around here it seems that a program called Senario (http://www.versiontracker.com/dyn/moreinfo/macosx/21086) would have been perfect because it describes launching or executing a script on those events, but it seems to not work with the leopard now. I know applescript can perform repeating tasks on idle, and that might work, but I can't figure out how to force quit something when the machine is no longer idle. If you're curious purpose of all of this is to set up a render farm in an office that will not effect other peoples CPU cycles. |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,551
|
Why don't you make your render-farm application a screensaver? That automatically launches when the computer is idle and quits when the computer is no longer idle, which seems to be exactly what you want without any added fuss.
Trevor
__________________
How to ask questions the smart way |
|
|
|
|
|
#3 |
|
League Commissioner
Join Date: Jan 2005
Posts: 8,475
|
Can you set the priority (man nice) of the app to be low enough that it can run all the time without interfering? I run Folding@home all the time when my 4 year old Dual G5 is on, and I've never noticed a performance hit because Folding@home is set to low priority by default.
|
|
|
|
|
|
#4 |
|
MVP
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
|
Here is an old script I had,that you can play with.
It will check the idle state every 20 seconds. if the idle state is less than 20 seconds ( i.e a key clicked in the last 20 seconds) then it will quit in this case textedit.app. if the idle time is more than 120 seconds ( no key clicked for a minute and half) it will launch textedit.app Code:
property idleCheck : 20 as integer
property idleCheck_usr : 120 as integer
set timer to 0
on idle
--Check idle time
set idletime to do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"
set idletime to idletime as string
set idletime to idletime as integer
tell application "System Events"
if idletime is less than idleCheck then (* 20 is 20 seconds. If a key was tapped
within the idleCheck seconds, it quits the app. *)
tell application "TextEdit" to quit
return idleCheck -- checks again in ... seconds
else
if idletime is greater than idleCheck_usr then (* If a key was tapped
after the idleCheck_usr seconds it t opens the app. *)
tell application "TextEdit" to launch
end if
return idleCheck --
end if
end tell
end idle
__________________
MH. |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Sep 2008
Posts: 2
|
Thanks for the replies, I'm sure one of these will work. The simplest sounds like making the app a screen saver, but I don't exactly see a way to choose the application from within the screen saver system preferences. Do I have to change the program in some way so it shows up as a screen saver?
looks like any of the other solutions can work too |
|
|
|
|
|
#6 | |||||||||||||||||||||||
|
Moderator
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,551
|
There's probably a more elegant way to make an app directly into a screensaver, but one method to make this work is to use ScriptSaver, which is a screensaver that will launch an Applescript. If that Applescript launches your app, that should work to start the app, although I'm not sure about automatically quitting your app when the computer ceases to be idle. Trevor
__________________
How to ask questions the smart way |
|||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|