From 1191a41fb2963fb255c65824efd97276f55f5586 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Fri, 1 May 2020 11:26:09 +0200 Subject: grimshot: Allow manually picking a window (with slurp) --- contrib/grimshot | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/grimshot b/contrib/grimshot index 6b94cb44..154e4a9f 100755 --- a/contrib/grimshot +++ b/contrib/grimshot @@ -32,7 +32,7 @@ FILE=${3:-$(getTargetDirectory)/$(date -Ins).png} if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then echo "Usage:" - echo " grimshot (copy|save) [win|screen|output|area] [FILE]" + echo " grimshot (copy|save) [active|screen|output|area|window] [FILE]" echo " grimshot check" echo " grimshot usage" echo "" @@ -43,10 +43,11 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" echo " usage: Show this message and exit." echo "" echo "Targets:" - echo " win: Currently active window." + echo " active: Currently active window." echo " screen: All visible outputs." echo " output: Currently active output." echo " region: Manually select a region." + echo " window: Manually select a window." exit fi @@ -106,7 +107,7 @@ if [ "$ACTION" = "check" ] ; then elif [ "$SUBJECT" = "area" ] ; then GEOM=$(slurp -d) WHAT="Area" -elif [ "$SUBJECT" = "win" ] ; then +elif [ "$SUBJECT" = "active" ] ; then FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"') APP_ID=$(echo "$FOCUSED" | jq -r '.app_id') @@ -118,6 +119,9 @@ elif [ "$SUBJECT" = "output" ] ; then GEOM="" OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') WHAT="$OUTPUT" +elif [ "$SUBJECT" = "window" ] ; then + GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) + WHAT="Window" else die "Unknown subject to take a screen shot from" "$SUBJECT" fi -- cgit v1.2.3