Posted on 01-26-2017 07:55 AM
I need to a way to attach a folder action script that I created to every users download folder. I know where the action scripts are stored, so I know how to get that into the right place. I just cant seem to figure out how to enable the action script through a deployment or using a terminal command.
Anyone have any ideas?
Solved! Go to Solution.
Posted on 01-26-2017 10:36 AM
I'd use a LaunchAgent and WatchFolder. Haven't tested this, but it should work....
But to test, put the file below in /Library/LaunchAgents/com.company.mygreatTool.plist and a script to to whatever in place of script.sh below. Every time the download folder gets touched, the script will run.
<?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>Label</key>
<string>com.company.mygreatTool</string>
<key>EnableGlobbing</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/path/to/script.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>~/Downloads/</string>
</array>
<key>OnDemand</key>
<true/>
</dict>
</plist>
Posted on 01-26-2017 10:36 AM
I'd use a LaunchAgent and WatchFolder. Haven't tested this, but it should work....
But to test, put the file below in /Library/LaunchAgents/com.company.mygreatTool.plist and a script to to whatever in place of script.sh below. Every time the download folder gets touched, the script will run.
<?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>Label</key>
<string>com.company.mygreatTool</string>
<key>EnableGlobbing</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/path/to/script.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>~/Downloads/</string>
</array>
<key>OnDemand</key>
<true/>
</dict>
</plist>
Posted on 01-26-2017 02:30 PM
Does launchd recognize ~ ?
Posted on 01-26-2017 02:35 PM
It does path expansion with the <key>EnableGlobbing</key>
key.
Posted on 01-26-2017 02:45 PM
Man I could kiss you right now! This just saved my life! Thanks buddy!