#!/usr/bin/env bash

# Screenshot script that saves image to clipboard first, then file path
# Usage: screenshot-script <mode>
# Modes: region, output, window

if [ $# -eq 0 ]; then
  echo "Usage: $0 <mode>"
  echo "Modes: region, output, window"
  exit 1
fi

mode="$1"
screenshot_dir="/mnt/synology/homes/jannick/View/library/screenshots"
filename="$(date +'%Y-%m-%d_%H-%M-%S').png"
filepath="$screenshot_dir/$filename"

# Ensure directory exists
mkdir -p "$screenshot_dir"

# Take screenshot and save to file + clipboard
hyprshot -m "$mode" -o "$screenshot_dir" -f "$filename"

# Wait a moment for the screenshot to complete
sleep 0.5

# Copy the absolute file path to clipboard (this will be the latest clipboard entry)
echo -n "$filepath" | wl-copy

# Send notification with file path
notify-send "Screenshot saved" "$filepath"
