diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-08 00:30:30 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-08 00:30:30 +1100 |
| commit | 619508b16c7089377d8413f9ee5506354f446ab1 (patch) | |
| tree | 9cf5cfcd57ca2d8e0380cb43e0a5ccf65b474225 /src/utils | |
| parent | update for scheme refactor (diff) | |
| download | caelestia-shell-619508b16c7089377d8413f9ee5506354f446ab1.tar.gz caelestia-shell-619508b16c7089377d8413f9ee5506354f446ab1.tar.bz2 caelestia-shell-619508b16c7089377d8413f9ee5506354f446ab1.zip | |
files: change directory monitor return
Only return the outermost monitor, hook onto that to cancel the nested ones
Also use the monitor flags in hopes of it actually picking up changes to files (it doesnt)
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/system.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/utils/system.ts b/src/utils/system.ts index d0470c7..518fb9a 100644 --- a/src/utils/system.ts +++ b/src/utils/system.ts @@ -78,18 +78,18 @@ export const bindCurrentTime = ( export const monitorDirectory = (path: string, callback: (path: string) => void, recursive?: boolean) => { const file = Gio.file_new_for_path(path.replace("~", HOME)); - const monitor = file.monitor_directory(null, null); + const monitor = file.monitor_directory(Gio.FileMonitorFlags.WATCH_MOUNTS | Gio.FileMonitorFlags.WATCH_MOVES, null); monitor.connect("changed", callback); - const monitors = [monitor]; - if (recursive) { const enumerator = file.enumerate_children("standard::*", null, null); let child; while ((child = enumerator.next_file(null))) - if (child.get_file_type() === Gio.FileType.DIRECTORY) - monitors.push(...monitorDirectory(`${path}/${child.get_name()}`, callback, recursive)); + if (child.get_file_type() === Gio.FileType.DIRECTORY) { + const m = monitorDirectory(`${path}/${child.get_name()}`, callback, recursive); + monitor.connect("notify::cancelled", () => m.cancel()); + } } - return monitors; + return monitor; }; |