FileMonitor#
- class ignis.utils.FileMonitor(path: str, recursive: bool = False, flags: gi.repository.Gio.FileMonitorFlags = gi.repository.Gio.FileMonitorFlags.NONE, callback: Callable | None = None, prevent_gc: bool = True)#
Monitor changes of the file or directory.
- Parameters:
path (
str) -- The path to the file or directory to be monitored.recursive (
bool, default:False) -- Whether monitoring is recursive (monitor all subdirectories and files).flags (
FileMonitorFlags, default:gi.repository.Gio.FileMonitorFlags.NONE) -- What the monitor will watch for. SeeGio.FileMonitorFlagsfor more info.callback (
Callable|None, default:None) -- A function to call when the file or directory changes. Seecallbackfor more info.prevent_gc (
bool, default:True) -- Whether to prevent the garbage collector from collecting this file monitor.
Example usage:
utils.FileMonitor( path="path/to/something", recursive=False, callback=lambda path, event_type: print(path, event_type), )
- signal changed#
Emitted when the file or directory changed.
- gproperty flags: gi.repository.Gio.FileMonitorFlags#
read-only
What the monitor will watch for.
See
Gio.FileMonitorFlagsfor more info.
- gproperty callback: Callable | None#
read-write
A function to call when the file or directory changes. It should take two arguments: 1. The path to the changed file or directory 2. The event type.
Event types:
changed
changes_done_hint
moved_out
deleted
created
attribute_changed
pre_unmount
unmounted
moved
renamed
moved_in
See
Gio.FileMonitorEventfor more info.
- gproperty recursive: bool#
read-only
Whether monitoring is recursive (monitor all subdirectories and files).