diff --git a/contrib/grimshot b/contrib/grimshot index 1ec19def6..111080ffa 100755 --- a/contrib/grimshot +++ b/contrib/grimshot @@ -44,7 +44,7 @@ ACTION=${1:-usage} SUBJECT=${2:-screen} FILE=${3:-$(getTargetDirectory)/$(date -Ins).png} -if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then +if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "savecopy" ] && [ "$ACTION" != "check" ]; then echo "Usage:" echo " grimshot [--notify] [--cursor] (copy|save) [active|screen|output|area|window] [FILE|-]" echo " grimshot check" @@ -53,6 +53,7 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" echo "Commands:" echo " copy: Copy the screenshot data into the clipboard." echo " save: Save the screenshot to a regular file or '-' to pipe to STDOUT." + echo " savecopy: Saves the screenshot to a regular file and copies the data into the clipboard." echo " check: Verify if required tools are installed and exit." echo " usage: Show this message and exit." echo "" @@ -153,16 +154,22 @@ else die "Unknown subject to take a screen shot from" "$SUBJECT" fi -if [ "$ACTION" = "copy" ] ; then - takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error" - notifyOk "$WHAT copied to buffer" -else - if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then - TITLE="Screenshot of $SUBJECT" - MESSAGE=$(basename "$FILE") - notifyOk "$MESSAGE" "$TITLE" - echo "$FILE" - else - notifyError "Error taking screenshot with grim" - fi -fi +case "$ACTION" in + copy) + takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error"; + notifyOk "$WHAT copied to buffer";; + save*) + if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then + if [ "$ACTION" = "savecopy" ]; then + wl-copy --type image/png < "$FILE" || die "Clipboard error" + fi + TITLE="Screenshot of $SUBJECT" + MESSAGE=$(basename "$FILE") + notifyOk "$MESSAGE" "$TITLE" + echo "$FILE" + else + notifyError "Error taking screenshot with grim" + fi;; + *) + die "Unexpected action: $ACTION" +esac