#!/bin/sh -e

dir="${XDG_SCREENSHOTS_DIR:-${HOME%/}/cloud/pictures/screenshots}"
mkdir "${dir}" >/dev/null 2>&1 || true
(
  fn=""
  cd "${dir}"
  if [ -z "${WAYLAND_DISPLAY}" ]; then
    fn="$(scrot -e 'echo $f')"
  else
    fn="$(date +'%Y-%m-%d-%H%M%S_grim.png')"
    grim "${fn}"
  fi
  echo "${dir}/${fn}"
)
