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

case "${1:-fullscreen}" in
  region)
    g=$(slurp -d); [ -z "$g" ] && exit 1
    grim -g "$g" - | wl-copy ;;
  window)
    g=$(mmsg get focusing-client | jq -r '"\(.x),\(.y) \(.width)x\(.height)"')
    [ -z "$g" ] && exit 1
    grim -g "$g" - | wl-copy ;;
  output)
      grim -o "$(mmsg get cursorpos | jq -r .monitor)" - | wl-copy;;
    *) grim - | wl-copy;;
esac
