#!/bin/bash
set -e

case "$1" in
    configure)
        # Add user to input group for keyboard access
        if ! groups | grep -q input; then
            echo "Adding user to input group..."
            usermod -a -G input $SUDO_USER 2>/dev/null || true
            echo "Please log out and log back in for input group to take effect."
        fi

        # Enable and start ydotool service
        if systemctl is-enabled ydotool.service >/dev/null 2>&1; then
            systemctl enable ydotool.service || true
            systemctl start ydotool.service || true
        fi

        echo ""
        echo "Alto has been installed successfully!"
        echo ""
        echo "Next steps:"
        echo "  1. Set your MISTRAL_API_KEY environment variable"
        echo "  2. Configure your push-to-talk key in /etc/alto/config.json"
        echo "  3. Run 'alto --detect-key' to find your preferred key"
        echo "  4. Start Alto with 'alto' or install the systemd service"
        echo ""
        ;;
esac

#DEBHELPER#

exit 0
