24 lines
542 B
Python
24 lines
542 B
Python
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 |