#!/usr/bin/env bash # Bash screenshot script. Requires grim, slurp, sway, fuzzel, libnotify and jq. IFS=$'\n' screenshot_targets=$(swaymsg -rt get_outputs | jq -r '.[].name' | sort) screenshot_targets+=($'\nSpecific region') # i LOVE bash selected_target="$(printf '%s' "${screenshot_targets[@]}" | fuzzel --hide-prompt --mesg='What would you like to screenshot?' --mesg-mode=expand --minimal-lines --dmenu)" outfile="$HOME/Pictures/Screenshots/$(date +'%F_%H.%M.%S.png')" send_notification() { notify-send "Screenshot taken" "Screenshot saved to $1." } case $selected_target in 'Specific region') grim -g "$(slurp)" "$outfile" && send_notification "$outfile";; *) grim -o "$selected_target" "$outfile" && send_notification "$outfile" ;; esac