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


Click here to return to the 'used launchd for ichatlocationscript and works fine' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
used launchd for ichatlocationscript and works fine
Authored by: nick on May 04, '05 09:24:15AM
i configured launchd to periodically run an applescript that changes the ichatstatus to my current network-location. it works fine. i made this plist-file in ~/Library/LaunchAgents :
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Debug</key>
        <false/>
        <key>Label</key>
        <string>iChatLocation</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>10</integer>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/bin/osascript</string>
                <string>/Users/niko/bin/ichatlocation.scpt</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>Change iChat Location to Network</string>
        <key>StartInterval</key>
        <integer>180</integer>
        <key>UserName</key>
        <string>niko</string>
</dict>
</plist>
it is labeled "iChatLocation", runs with low IO priority and with nice 10, starts an applescript in the bin-folder in my homedir, runs at load (maybe i wouldn't need that) and then every 180 seconds with my (niko) userrights. even better of course would be, if s/o figured out how to run stuff at network-changes. i started it with:
Nikomat:~ niko$ launchctl load Library/LaunchAgents/iChatLocation.plist
i can check, that its running:
Nikomat:~ niko$ launchctl list
iChatLocation
Nikomat:~ niko$


[ Reply to This | # ]
configd better than launchd
Authored by: hughescr on May 04, '05 07:14:18PM
The way you run stuff at network switches rather than periodically is to hook into configd, not launchd. See here for details.

[ Reply to This | # ]
configd better than launchd / right...
Authored by: nick on May 05, '05 09:44:50AM

...but when i think about it... perhaps in my case its better to run stuff periodically as the script exits anyway if nothing has changed AND more important it relies on ichat having logged in... which usually isn't the case immediatelly after the networkchange, but some 10 seconds later...



[ Reply to This | # ]
used launchd for ichatlocationscript and works fine
Authored by: jonbauman on May 06, '05 11:35:17PM

You actually don't need to set the user explicitly if you put it in your own ~/Library/LaunchAgents directory. The default is to run as the user that added the agent to launchd.

One thing I can't figure out is how to run commands with spaces in the name. I've tried quoting, no quoting, and backslash escaping, but nothing seems to work

---
jon

[ Reply to This | # ]