On 8 Mar 2017, at 06:33, Jean-Christophe Helary <email@hidden> wrote:
Is there a way to trigger folder actions by doing something like changing it's tag, or something that's not related to putting files there.
Actually, yes, but you’ll need a different automation tool and a different language. It’s fairly simple, and free to use.
The tool is called hammerspoon:
and the language is called lua:
You don’t need to learn it though just to achieve this. Download and set up Hammerspoon, and put this code in the config file:
function myFolderWatch() hs.alert.show("Launch Agents folder was modified") end
local aWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/Library/LaunchAgents/", myFolderWatch):start()
That will trigger an alert whenever anything is done to the User’s Launch Agents folder (including setting tags). Obviously change the path to whatever folder you want in the aWatcher variable.
Equally, you could have somethings else other than an alert shown occur when the code is triggered. One of the nice things is you can call osascript (ie. applescript) from hammer spoon, too, so instead of the hs.alert you could run any applescript you like.
If you explore the documentation for hammer spoon, you’ll see there’s a lot of system APIs in there. The pathwatcher one used here works by calling low level apple code, FSEventStream. I don’t know if this can be bridged to through ASObjC. If so, Shane might be able to rig up a direct AppleScript replacement. That said, hammerspoon is worth exploring anyway; there’s a lot of cool automation tricks you can do with it out of the box, and even more it you learn lua (which is not surprising applescript-like in some parts of its syntax and literally took me about an hour to learn enough to write my own functions).
Best
Phil
|