#!/usr/bin/env bash # The rofi prompt PROMPT="Screenshot" # Actions for the menu ACTIONS=( "1: Fullscreen" "2: Selection" "3: Window" "4: Delayed" ) FILENAME="$(xdg-user-dir PICTURES)/screenshots/$(date +"%Y-%m-%dT%H%M%S").png" SELECTION=$(printf '%s\n' "${ACTIONS[@]}" | fuzzel -dmenu -I| cut -d ":" -f1) case "${SELECTION}" in "1") grim - | tee "${FILENAME}" | wl-copy ;; "2") grim -g "$(slurp)" - | tee "${FILENAME}" | wl-copy ;; "3") grim -g "$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)" - | tee "${FILENAME}" | wl-copy ;; "4") sleep 3 && grim - | tee "${FILENAME}" | wl-copy ;; esac