#!/usr/bin/env bash
#
# Remote Mouse Suite — Linux installer.
#
# Installs the Remote Mouse Suite helper binary into the user's local bin
# X11, copies the RemoteMouseSuite binary into ~/.local/bin, and prints how to
# run it. Re-runnable and safe: it only ever touches your own user account
# (no system-wide changes beyond the xclip package install, which needs sudo).

set -euo pipefail

APP="RemoteMouseSuite"
BIN_DIR="${HOME}/.local/bin"
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo "=============================================="
echo " Remote Mouse Suite — Linux install"
echo "=============================================="

# ---------------------------------------------------------------------------
# 1. Install the binary into the user's local bin.
# ---------------------------------------------------------------------------
echo "[1/1] Installing ${APP} → ${BIN_DIR}/${APP}"
mkdir -p "${BIN_DIR}"
install -m 0755 "${SRC_DIR}/${APP}" "${BIN_DIR}/${APP}"

echo
echo "Done."
echo
echo "Run it with:"
echo "    ${BIN_DIR}/${APP}"
case ":${PATH}:" in
  *":${BIN_DIR}:"*)
    echo "(You can also just type '${APP}' — ${BIN_DIR} is on your PATH.)" ;;
  *)
    echo
    echo "Note: ${BIN_DIR} is not on your PATH. Add this to ~/.bashrc:"
    echo "    export PATH=\"\$HOME/.local/bin:\$PATH\"" ;;
esac
echo
echo "Start automatically at login (optional):"
echo "    ${BIN_DIR}/${APP} --install-autostart"
echo
echo "Wayland users: pynput can move the mouse but often cannot type keys."
echo "For full keyboard support, choose an 'Xorg' / X11 session at login."
