Yes, I put it in the Library of the specific user.
I have two users on my mac: UserA and UserB
I put the following .plist file in /Users/UserA/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>Label</key>
<string>WatchingVolumesFolder123</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>/usr/bin/osascript</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/UserA/Library/Scripts/launchd/WatchingVolumesFolder123.scpt</string>
</array>
<key>ServiceDescription</key>
<string>AppleScript directly when Volumes changes</string>
<key>WatchPaths</key>
<array>
<string>/Volumes</string>
</array>
</dict>
</plist>
I created an AppleScript with the name and path of the ProgramArguments.
I start the computer without the drive connected. I log in to UserA, I then switch and login to UserB, without logging out UserA.
If I plug in the external drive while UserB is active, the launchd job in the Library of UserA does nothing.
It only does what it is supposed to do if I plug in the drive while UserA is active.
I'm wondering if there is anyway to get it to work on UserA, without ever switching back to UserA, so just have it perform in the background.
If it is not possible, I will just set it up, so I put the launchd on UserB, and kick of the task by login in to UserA with shellscript and ssh user@localhost, but I'd prefer not to.