#!/bin/sh if ! type xdg-user-dir; then notify-send "xdg-user-dir is not installed" "Install it with your system package manager" exit fi TYPE="$(printf "Window/Area\nScreen" | dmenu -i -p 'What do you want to screenshot?')" [ -z "$TYPE" ] && exit [ "$TYPE" = "Window/Area" ] && TIME_DEFAULT="0" || TIME_DEFAULT="1" WHERE="$(printf "Copy\nSave" | dmenu -i -p 'Do you want to save or copy to clipboard?')" [ -z "$WHERE" ] && exit TIME="$(printf "%s\n5\n10\n15" "$TIME_DEFAULT" | dmenu -i -p 'How many seconds do you want to wait?')" [ -z "$TIME" ] && exit case "$TYPE" in Window/Area) TYPE="-s -u";; Screen) TYPE="" esac mkdir -p "$(xdg-user-dir PICTURES)"/Screenshot 2>/dev/null sleep "$TIME" # shellcheck disable=SC2086 case "$WHERE" in Copy) maim $TYPE | xclip -selection clipboard -t image/png;; Save) maim $TYPE "$(xdg-user-dir PICTURES)/Screenshot/$(date +%G-%m-%d_%s.png)" esac