summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinko Kašljević <vinko.kasljevic@gmail.com>2020-07-15 18:31:09 +0200
committerSimon Ser <contact@emersion.fr>2020-07-15 19:27:13 +0200
commita314deeaa3f5521a5ceae631682c953b6d2c9d29 (patch)
tree27e204a19ba58df2514000a204d7646fc9bf8825
parent105c69d431389aecb908cccfce3712f77251ccde (diff)
Add check for empty GEOM variable
In case when slurp is used to select part of screen or a window, if user aborts the selection, grimshot will capture the whole screen instead of exiting. This is fixed with check for empty variable. (cherry picked from commit c65cd1cffa5a791202ee913afef40dffdc54e5bc)
-rwxr-xr-xcontrib/grimshot8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/grimshot b/contrib/grimshot
index 4ee8d902c..461a5eeff 100755
--- a/contrib/grimshot
+++ b/contrib/grimshot
@@ -111,6 +111,10 @@ if [ "$ACTION" = "check" ] ; then
exit
elif [ "$SUBJECT" = "area" ] ; then
GEOM=$(slurp -d)
+ # Check if user exited slurp without selecting the area
+ if [ -z "$GEOM" ]; then
+ exit
+ fi
WHAT="Area"
elif [ "$SUBJECT" = "active" ] ; then
FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)')
@@ -126,6 +130,10 @@ elif [ "$SUBJECT" = "output" ] ; then
WHAT="$OUTPUT"
elif [ "$SUBJECT" = "window" ] ; then
GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
+ # Check if user exited slurp without selecting the area
+ if [ -z "$GEOM" ]; then
+ exit
+ fi
WHAT="Window"
else
die "Unknown subject to take a screen shot from" "$SUBJECT"