| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # wayshot — screenshot on Wayland using grim |
| 4 | # deps: grim (capture); optional: slurp (region select), wl-clipboard, libnotify |
| 5 | |
| 6 | set -euo pipefail |
| 7 | |
| 8 | DIR="${SCREENSHOT_DIR:-$HOME/Pictures/screenshots}" |
| 9 | mkdir -p "$DIR" |
| 10 | FILE="$DIR/screenshot_$(date +%Y%m%d_%H%M%S).png" |
| 11 | |
| 12 | # Pass "-r" or "-f" for full screen, default is region-select |
| 13 | GEO=() |
| 14 | if [[ "${1:-}" != "-f" ]]; then |
| 15 | GEO=(-g "$(slurp)") # Ctrl+C or Esc to cancel |
| 16 | fi |
| 17 | |
| 18 | grim -t png "${GEO[@]}" "$FILE" |
| 19 | |
| 20 | # Optional: copy to clipboard + notify |
| 21 | command -v wl-copy >/dev/null && wl-copy < "$FILE" |
| 22 | command -v notify-send >/dev/null && notify-send "Screenshot saved" "$FILE" |
| 23 | |
| 24 | echo "$FILE" |