diff --git a/contrib/grimshot b/contrib/grimshot index 7757d6ce..bbb35e33 100755 --- a/contrib/grimshot +++ b/contrib/grimshot @@ -15,6 +15,7 @@ ## `grimshot copy win` - to copy current window ## `grimshot save area` - to select area and save it to default file (Pictures/Grimshot-$datetime.png) ## `grimshot save screen ~/screenshot.png` - to save screenshot under ~/screenshot.png +## `grimshot save output ~/screenshot.png` - to save screenshot under ~/screenshot.png ## `grimshot` - usage ## `grimshot check` - verify if tools are installed @@ -23,7 +24,7 @@ SUBJECT=${2:-screen} FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')} if [ "$ACTION" = "usage" ] ; then echo "Usage:" - echo " grimshot copy|save win|screen|focused_screen|area [FILE]" + echo " grimshot copy|save win|screen|output|area [FILE]" echo "Troubleshoot:" echo " grimshot check" exit @@ -62,9 +63,9 @@ check() { takeScreenshot() { FILE=$1 GEOM=$2 - SCREEN=$3 - if [ ! -z "$SCREEN" ]; then - grim -o "$SCREEN" "$FILE" || die "Unable to invoke grim" + OUTPUT=$3 + if [ ! -z "$OUTPUT" ]; then + grim -o "$OUTPUT" "$FILE" || die "Unable to invoke grim" elif [ -z "$GEOM" ]; then grim "$FILE" || die "Unable to invoke grim" else @@ -93,22 +94,22 @@ elif [ "$SUBJECT" = "win" ] ; then elif [ "$SUBJECT" = "screen" ] ; then GEOM="" WHAT="Screen" -elif [ "$SUBJECT" = "focused_screen" ] ; then +elif [ "$SUBJECT" = "output" ] ; then GEOM="" - SCREEN=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') - WHAT="Focused screen $SCREEN" + OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') + WHAT="$OUTPUT" else die "Unknown subject to take a screen shot from" "$SUBJECT" fi if [ "$ACTION" = "copy" ] ; then TMP=$(mktemp) || die "Unable to create temp file: is mktemp installed?" - takeScreenshot "$TMP" "$GEOM" "$SCREEN" + takeScreenshot "$TMP" "$GEOM" "$OUTPUT" wl-copy --type image/png < "$TMP" || die "Clipboard error" rm "$TMP" notifyOk "$WHAT copied to buffer" else - if takeScreenshot "$FILE" "$GEOM" "$SCREEN"; then + if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then TITLE="Screenshot of $SUBJECT" MESSAGE=$(basename "$FILE") notifyOk "$MESSAGE" "$TITLE"