Page 1 of 1

Trigger off of a file changing?

PostPosted: Sun Feb 25, 2018 7:41 pm
by ZachBenz
Is there a way to trigger based on a file on disk changing (e.g. being created/updated/deleted)? I feel like there was a plugin at some point that could watch a file for changes, but I can't for the life of me find it now.

Re: Trigger off of a file changing?

PostPosted: Wed Feb 28, 2018 9:01 pm
by mundmc
Somebody may have made a mac system-level plugin, though i can’t remember either.

I don’t know exactly how, but I know it can be done using
1) folder actions
2) automator, running a...
3) ... shell script that cURL’s the relevant info to Indigo’s RESTful interface

I have to guess- you doing an IFTTT trigger?


Sent from my iPhone using Tapatalk

Re: Trigger off of a file changing?

PostPosted: Sun Mar 04, 2018 2:50 pm
by ZachBenz
Not IFTTT in my case, something a bit more esoteric (I want to trigger off of when a specific file is downloaded by a particular plugin). I think the solution I actually want is to write the python to add the specific trigger I want to another plugin (the Ring plugin in this case). That is, instead of kludging things by watching the file system for changes, just have the plugin tell me when the thing that I'm interested in has finished.

Re: Trigger off of a file changing?

PostPosted: Mon Mar 05, 2018 11:04 pm
by howartp
Try asking the Ring author - they might add the trigger right in the plugin for you.


Sent from my iPhone using Tapatalk Pro

Re: Trigger off of a file changing?

PostPosted: Tue Mar 06, 2018 11:19 am
by Colorado4Wheeler
How deep do you want to go with this? It's possible in Py to watch for a file but you'll likely need to do this in a plugin so it can thread and loop without hanging Indigo. Here's an example how to do this in Py:

Code: Select all
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler

def watchForFile (self, path):
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')
    event_handler = LoggingEventHandler()
    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()

Re: Trigger off of a file changing?

PostPosted: Tue Mar 06, 2018 9:48 pm
by ZachBenz
Thanks, C4W.

I've already been making edits to the Ring plugin (and submitting them via pull requests), so I'm happy to muck about some more. :-)