#!/bin/bash

# Toggle Dictation Service Control Script
# This script creates/removes the dictation lock file to control AI dictation state

DICTATION_DIR="/mnt/storage/Development/dictation-service"
LOCK_FILE="$DICTATION_DIR/listening.lock"
CONVERSATION_LOCK_FILE="$DICTATION_DIR/conversation.lock"

if [ -f "$LOCK_FILE" ]; then
    # Stop dictation
    rm "$LOCK_FILE"
    notify-send "🎤 Dictation Stopped" "Press Alt+D to resume"
    echo "$(date): AI dictation stopped" >> /tmp/dictation.log
else
    # Stop conversation if running, then start dictation
    if [ -f "$CONVERSATION_LOCK_FILE" ]; then
        rm "$CONVERSATION_LOCK_FILE"
        echo "$(date): Conversation stopped (dictation mode)" >> /tmp/conversation.log
    fi
    
    # Start dictation
    touch "$LOCK_FILE"
    notify-send "🎤 Dictation Started" "Speak now"
    echo "$(date): AI dictation started" >> /tmp/dictation.log
fi
