Re: Any Way to Force an Idle Handler System Call? (Redux)
Re: Any Way to Force an Idle Handler System Call? (Redux)
- Subject: Re: Any Way to Force an Idle Handler System Call? (Redux)
- From: "S. J. Cunningham" <email@hidden>
- Date: Sun, 08 Jun 2014 06:33:43 -0400
On Jun 7, 2014, at 5:16 PM, Ted Wrigley wrote:
> Apparently, by the time the idle loop begins running the next idle call is already set by the system. That’s one of the side effects of applescript not being multi-threaded; I don’t see any way of clearing that unless there’s a unix trick that will manage it. However, this seems more like a problem of script structure: it seems to me you could easily plan around this. Assuming this is the same problem that was floating around before (with the camera system and the email notification), the simple expedient of quitting and restarting the app should suffice.
>
> If I were doing this I’d switch to a combined approach. Use the applescript app with the two hour idle loop as you have it, but launch it via launchd. Save the following as a plain text file in ~/LaunchAgents/user.timer.reset.plist, obviously putting the correct path to the script app in line 8, then load it into launchd by logging in again or running the command launchctl load ~/LaunchAgents/user.timer.reset.plist in Terminal.app.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
> <plist version="1.0">
> <dict>
> <key>Label</key>
> <string>user.timer.reset</string>
> <key>Program</key>
> <string>/path/to/scriptapp.app</string>
> <key>KeepAlive</key>
> <true/>
> </dict>
> </plist>
Ted,
Thanks. I'll make use of this with Shane's modification.
> This plist will launch the app when it loads and make sure the app stays open continuously. When you want to reset the idle loop (i.e., when you get the correct email) simply quit the script app. launchd will immediately restart it, resetting the idle loop.
The problem is I can't figure out how to "simply quit the app"... hence the question. If the app is snoozing in the idle state, it can't quit itself. Nor, apparently can an external app tell it to quit. The only way I have been able to figure out how to do it is
do shell script "killall applet"
Ugly, but it works. Raises the question as to what will happen if another "applet" is running somewhere :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden