#!/bin/sh

# Screenshot tool using scrot with dunst notifications
# Usage: screenshot [full|select|window]

DIR="$HOME/Pictures/Screenshots"
mkdir -p "$DIR"
TIMESTAMP=$(date '+%Y-%m-%d_%H-%M-%S')
FILE="$DIR/ss-${TIMESTAMP}.png"

case "${1:-full}" in
	full)
		scrot "$FILE"
		;;
	select)
		notify-send -t 1500 "󰹑 Screenshot" "Select a region..."
		sleep 0.2
		scrot -s -l style=dash,width=2,color="#80A0C0" "$FILE"
		;;
	window)
		scrot -u "$FILE"
		;;
	*)
		echo "Usage: screenshot [full|select|window]"
		exit 1
		;;
esac

if [ -f "$FILE" ]; then
	xclip -selection clipboard -t image/png < "$FILE"
	notify-send -t 3000 -i "$FILE" "󰹑 Screenshot Saved" "$FILE"
else
	notify-send -t 2000 -u critical "󰹑 Screenshot" "Cancelled or failed"
fi
