1

I am trying to create a user LaunchAgents that will trigger a script when a path managed by a sandbox app will change (in my case, when /Library/Containers/com.omnigroup.OmniFocus3/Data/Library/Application\ Support/OmniFocus/OmniFocus.ofocus will change).

For this, I want to use the WatchPaths key of launchd, I already tried with a Folder Action, but those are limited to file addition in a folder.

I have made a working test to listen on a file and folder in my home directory and trigger a notification. e.g.:

<?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>me.mayeu.helloworld</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/bin/terminal-notifier</string>
            <string>-message</string>
            <string>Test</string>      
        </array>
        <key>WatchPaths</key>
        <array>
                <string>/Users/me/watchtest/</string>
        </array>
</dict>
</plist>

This works well for whatever changes happen under the watchtest folder.

But when I replace the WatchPaths key with the OmniFocus database, this does not work anymore (no notification are triggered):

<?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>me.mayeu.script.OmniListen</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/bin/terminal-notifier</string>
      <string>-message</string>
      <string>Test</string>
    </array>
    <key>WatchPaths</key>
    <array>
      <string>/Users/me/Library/Containers/com.omnigroup.OmniFocus3/Data/Library/Application\ Support/OmniFocus/OmniFocus.ofocus</string>
    </array>
  </dict>
</plist>

I have a feeling that this is due to the sandboxing of the app. But I can't find any documentation about that.

I am using macOS Mojave 10.14.2.

0

So I found the solution. And it has nothing to do with sandboxing, but everything to do with the fact that I had a \ in my path because I copied it over from the shell.

e.g.: .../Data/Library/Application\ Support/... should be .../Data/Library/Application Support/....

You must log in to answer this question.

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