#!/bin/bash
set -e

echo "Building klp..."
make build

echo "Installing to ~/.local/bin..."
make install

echo "Creating config directory..."
mkdir -p ~/.config/klp

# Ensure ~/.local/bin is in PATH for this script
export PATH="$HOME/.local/bin:$PATH"

echo "Starting clipboard monitor daemon..."
klp service start

echo ""
echo "Installation complete!"
echo ""
echo "Make sure ~/.local/bin is in your PATH (add to ~/.bashrc or ~/.zshrc):"
echo '  export PATH="$HOME/.local/bin:$PATH"'
echo ""
echo "Service management:"
echo "  klp service status   # Check if daemon is running"
echo "  klp service stop     # Stop the daemon"
echo "  klp service start    # Start the daemon"
echo ""
echo "For auto-start on login, choose one:"
echo "  make service-install   # systemd user service"
echo "  make autostart-install # desktop autostart entry"
echo ""
echo "Usage:"
echo "  klp              # Interactive list"
echo "  klp -l           # Non-interactive list"
echo "  klp <id>         # Copy entry to clipboard"
echo "  klp -s 'query'   # Search"
echo "  klp -d <id>      # Delete entry"
echo "  klp -v           # Version"
