#!/usr/bin/env bash
# 
# SCRIPT NAME:
# screenshot
#
# AUTHOR:
# Severin Kaderli <severin@kaderli.dev>
#
# DESCRIPTION:
# Displays a screenshot menu using rofi.
#
# USAGE:
# ./screenshot

# The rofi prompt
PROMPT="Screenshot"

# Actions for the menu
ACTIONS=(
    "1: Fullscreen"
    "2: Selection"
)

FILENAME="${HOME}/pictures/screenshots/%Y-%m-%dT%H%M%S.png"

SELECTION=$(printf '%s\n' "${ACTIONS[@]}" | rofi -dmenu -i -p "${PROMPT}" | cut -d ":" -f1)
case "${SELECTION}" in
    "1")
        FILE=$(escrotum "${FILENAME}")
        ;;
    "2")
        FILE=$(escrotum -s "${FILENAME}")
        ;;
esac

# Save the screenshot also in the clipboard
TYPE=$(file -b --mime-type "${FILE}")
xclip -selection clipboard -t "${TYPE}" < "${FILE}"