aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/grimshot10
1 files 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}
32 32
33if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then 33if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
34 echo "Usage:" 34 echo "Usage:"
35 echo " grimshot (copy|save) [win|screen|output|area] [FILE]" 35 echo " grimshot (copy|save) [active|screen|output|area|window] [FILE]"
36 echo " grimshot check" 36 echo " grimshot check"
37 echo " grimshot usage" 37 echo " grimshot usage"
38 echo "" 38 echo ""
@@ -43,10 +43,11 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check"
43 echo " usage: Show this message and exit." 43 echo " usage: Show this message and exit."
44 echo "" 44 echo ""
45 echo "Targets:" 45 echo "Targets:"
46 echo " win: Currently active window." 46 echo " active: Currently active window."
47 echo " screen: All visible outputs." 47 echo " screen: All visible outputs."
48 echo " output: Currently active output." 48 echo " output: Currently active output."
49 echo " region: Manually select a region." 49 echo " region: Manually select a region."
50 echo " window: Manually select a window."
50 exit 51 exit
51fi 52fi
52 53
@@ -106,7 +107,7 @@ if [ "$ACTION" = "check" ] ; then
106elif [ "$SUBJECT" = "area" ] ; then 107elif [ "$SUBJECT" = "area" ] ; then
107 GEOM=$(slurp -d) 108 GEOM=$(slurp -d)
108 WHAT="Area" 109 WHAT="Area"
109elif [ "$SUBJECT" = "win" ] ; then 110elif [ "$SUBJECT" = "active" ] ; then
110 FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') 111 FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)')
111 GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"') 112 GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"')
112 APP_ID=$(echo "$FOCUSED" | jq -r '.app_id') 113 APP_ID=$(echo "$FOCUSED" | jq -r '.app_id')
@@ -118,6 +119,9 @@ elif [ "$SUBJECT" = "output" ] ; then
118 GEOM="" 119 GEOM=""
119 OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') 120 OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name')
120 WHAT="$OUTPUT" 121 WHAT="$OUTPUT"
122elif [ "$SUBJECT" = "window" ] ; then
123 GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
124 WHAT="Window"
121else 125else
122 die "Unknown subject to take a screen shot from" "$SUBJECT" 126 die "Unknown subject to take a screen shot from" "$SUBJECT"
123fi 127fi