0

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?

0

1 Answer 1

2

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>
1
  • Thanks a bunch Lri! Guess I need to sort out my desktop paths better :-x
    – Jroen
    Commented May 14, 2012 at 16:26

You must log in to answer this question.

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