#!/bin/sh if ! type scrot > /dev/null; then >&2 echo "!!! scrot is not installed" exit 1 fi picturesDir=`xdg-user-dir PICTURES` test -z "$picturesDir" && picturesDir="$HOME/Pictures" picturesDir="$picturesDir/Screen Shots" if ! mkdir -p "$picturesDir"; then >&2 echo "!!! can't create $picturesDir" exit 1 fi output="$picturesDir/`date -Iseconds`.png" case "$1" in "selection") scrot --select --line style=dash --freeze --file "$output" clipArg="$2" ;; "window") scrot --focused --border --file "$output" clipArg="$2" ;; *) scrot --file "$output" clipArg="$1" ;; esac if test "$clipArg" = "clipboard"; then xclip -selection clipboard -target image/png -i "$output" fi