diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/services/wallpapers.ts | 4 | ||||
| -rw-r--r-- | src/utils/system.ts | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/services/wallpapers.ts b/src/services/wallpapers.ts index 39bced4..9a4e5bb 100644 --- a/src/services/wallpapers.ts +++ b/src/services/wallpapers.ts @@ -58,10 +58,10 @@ export default class Wallpapers extends GObject.Object { let monitors = config.paths .get() - .flatMap(p => monitorDirectory(p.path, () => this.update().catch(console.error), p.recursive)); + .map(p => monitorDirectory(p.path, () => this.update().catch(console.error), p.recursive)); config.paths.subscribe(v => { for (const m of monitors) m.cancel(); - monitors = v.flatMap(p => monitorDirectory(p.path, () => this.update().catch(console.error), p.recursive)); + monitors = v.map(p => monitorDirectory(p.path, () => this.update().catch(console.error), p.recursive)); }); } } 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; }; |