import subprocess from pathlib import Path def start_inotify_watcher(path: str, callback=None): """ Startet einen Inotify-Watcher mit dem Befehl 'inotifywait'. Callback wird aufgerufen bei Dateiänderungen. """ # Useinotifywait from inotify-tools package command = [ "inotifywait", "-m", "-r", "--format '%w%f %e'", str(path) ] process = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True ) return process