Created
July 23, 2022 16:09
-
-
Save yilozt/775d31281f6c55341222fdd7400fc759 to your computer and use it in GitHub Desktop.
Watch Directory With Gio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GLib = imports.gi.GLib | |
const Gio = imports.gi.Gio | |
const loop = new GLib.MainLoop (null, false) | |
const home = GLib.get_home_dir () | |
const file = Gio.File.new_for_path (home + '/a/b') | |
const monitor = file.monitor (Gio.FileMonitorFlags.WATCH_MOVES, null) | |
monitor.connect ('changed', (monitor, file, otherFile, eventType) => { | |
log (monitor) | |
switch (eventType) { | |
case Gio.FileMonitorEvent.CREATED: | |
console.log (`${file.get_path ()} was created`) | |
} | |
}) | |
loop.run () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment