Add macOS file watcher and improve symlink support

- Add watch_macos.sh script using fswatch with symlink support

- Enable symlink following in Python watchdog script
This commit is contained in:
Gigi
2025-04-01 09:54:43 +01:00
parent d440c63d0c
commit 1e153ffeba
2 changed files with 57 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import os
import sys
import time
import subprocess
@@ -133,7 +134,7 @@ def main():
observer = Observer()
# Watch all directories
observer.schedule(event_handler, str(voice_memo_dir), recursive=False)
observer.schedule(event_handler, os.path.realpath(str(voice_memo_dir)), recursive=False)
observer.schedule(event_handler, str(transcript_dir), recursive=False)
observer.schedule(event_handler, str(summary_dir), recursive=False)

55
watch_macos.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# Directory paths
VOICE_MEMO_DIR="VoiceMemos"
TRANSCRIPT_DIR="$VOICE_MEMO_DIR/transcripts"
# Check if directories exist
if [ ! -d "$VOICE_MEMO_DIR" ]; then
echo "Error: $VOICE_MEMO_DIR directory does not exist"
exit 1
fi
if [ ! -d "$TRANSCRIPT_DIR" ]; then
echo "Error: $TRANSCRIPT_DIR directory does not exist"
exit 1
fi
# Function to process voice memos
process_voice_memo() {
echo "New voice memo detected!"
./process_voice_memos.sh
}
# Function to process transcripts
process_transcript() {
echo "New transcript detected!"
./summarize_transcripts.py
}
echo "Starting file watcher..."
echo "Watching for changes in:"
echo "- Voice memos: $VOICE_MEMO_DIR"
echo "- Transcripts: $TRANSCRIPT_DIR"
echo "Press Ctrl+C to stop..."
# Monitor both directories in parallel
# -L flag enables following symlinks
(
fswatch -L -o "$VOICE_MEMO_DIR" | while read -r f; do
if [[ "$f" =~ \.m4a$ ]]; then
process_voice_memo
fi
done
) &
(
fswatch -L -o "$TRANSCRIPT_DIR" | while read -r f; do
if [[ "$f" =~ \.txt$ ]]; then
process_transcript
fi
done
) &
# Wait for Ctrl+C
wait