#!/usr/bin/env bash
set -euo pipefail

if [[ $# -ne 1 ]]; then
  echo "Usage: $0 <interval_seconds>"
  exit 2
fi

INTERVAL="$1"
if ! [[ "$INTERVAL" =~ ^[0-9]+([.][0-9]+)?$ ]] || [[ "$INTERVAL" == "0" ]] || [[ "$INTERVAL" == "0.0" ]]; then
  echo "interval_seconds must be > 0 (integer or decimal)"
  exit 2
fi

if ! command -v tmux >/dev/null 2>&1; then
  echo "tmux not found"
  exit 3
fi

if ! tmux has-session -t claude 2>/dev/null; then
  echo "tmux session '4 - claude' not found"
  exit 4
fi

trap 'exit 0' INT TERM

while true; do
  tmux send-keys -t claude Enter
  sleep "$INTERVAL"
done
