Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Snowleopard 10.6.8 on a Macmini server and I want this server to execute a script whenever a file or folder is inserted/edited or deleted from a specified folder. Since I'd like this behaviour to work over the network when the system is on (but not logged in) I made a .plist script which is set as a LaunchDeamon. The .plist has the same rights as all my other .plists: "System: read&write. Wheel & Everyone: read only"

As a testcase I set up the following script with a little help from lingon 2.1. This script should execute growltime.scpt, whenever the Desktop (<WatchPaths>) detects a change or when something is mounted (<StartOnMount>).

<?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>com.watchfolder.growltime</string>
    <key>ProgramArguments</key>
    <array>
    <string>osascript /Users/admin/growltime.scpt</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartOnMount</key>
    <true/>
    <key>WatchPaths</key>
    <array>
    <string>/Users/admin/Library/Desktop/</string>
    </array>
</dict>
</plist>

Now the strange thing is, growltime.scpt will ONLY run when I mount a disk or an installation file is mounted (<StartOnMount>), but NOT when a file or folder has been inserted/edited or deleted within the Desktop (<WatchPaths>).

What am I doing wrong here?

share|improve this question
up vote 2 down vote accepted

First of all it shouldn't work at all unless each word in ProgramArguments is a separate string. Instead of this

<key>ProgramArguments</key>
<array>
<string>osascript /Users/admin/growltime.scpt</string>
</array>

it should be

<key>ProgramArguments</key>
<array>
        <string>osascript</string>
        <string>/Users/admin/growltime.scpt</string>
</array>

Did you maybe have an older version of the agent loaded when you were testing it? The property lists can be reloaded with launchctl unload ~/Library/LaunchAgents/$id.plist && launchctl load ~/Library/LaunchAgents/$id.plist.

You also had an error in the path for the desktop:

<key>WatchPaths</key>
<array>
<string>/Users/admin/Library/Desktop/</string>
</array>
share|improve this answer
    
Thanks a bunch Lri! Guess I need to sort out my desktop paths better :-x – Jroen May 14 '12 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .