• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: other folder actions ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: other folder actions ?


  • Subject: Re: other folder actions ?
  • From: 2551phil <email@hidden>
  • Date: Wed, 08 Mar 2017 08:09:26 +0700


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:

http://www.hammerspoon.org

and the language is called lua:

https://www.lua.org

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












 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: other folder actions ?
      • From: Stan Cleveland <email@hidden>
    • Re: other folder actions ?
      • From: Shane Stanley <email@hidden>
References: 
 >other folder actions ? (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: Folder Actions on finder icon
  • Next by Date: Re: Folder Actions on finder icon
  • Previous by thread: Re: other folder actions ?
  • Next by thread: Re: other folder actions ?
  • Index(es):
    • Date
    • Thread