diff options
author | Hugo Osvaldo Barrera <hugo@barrera.io> | 2020-05-01 11:26:09 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-05-05 20:18:19 +0200 |
commit | 1191a41fb2963fb255c65824efd97276f55f5586 (patch) | |
tree | d5d3a728b564da0bbe91279c2e624151a6621057 | |
parent | grimshot: Show usage when on invalid command (diff) | |
download | sway-1191a41fb2963fb255c65824efd97276f55f5586.tar.gz sway-1191a41fb2963fb255c65824efd97276f55f5586.tar.zst sway-1191a41fb2963fb255c65824efd97276f55f5586.zip |
grimshot: Allow manually picking a window
(with slurp)
-rwxr-xr-x | contrib/grimshot | 10 |
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 | ||
33 | if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then | 33 | if [ "$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 |
51 | fi | 52 | fi |
52 | 53 | ||
@@ -106,7 +107,7 @@ if [ "$ACTION" = "check" ] ; then | |||
106 | elif [ "$SUBJECT" = "area" ] ; then | 107 | elif [ "$SUBJECT" = "area" ] ; then |
107 | GEOM=$(slurp -d) | 108 | GEOM=$(slurp -d) |
108 | WHAT="Area" | 109 | WHAT="Area" |
109 | elif [ "$SUBJECT" = "win" ] ; then | 110 | elif [ "$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" |
122 | elif [ "$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" | ||
121 | else | 125 | else |
122 | die "Unknown subject to take a screen shot from" "$SUBJECT" | 126 | die "Unknown subject to take a screen shot from" "$SUBJECT" |
123 | fi | 127 | fi |