diff options
author | Vinko Kašljević <vinko.kasljevic@gmail.com> | 2020-07-15 18:31:09 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-07-15 18:49:32 +0200 |
commit | c65cd1cffa5a791202ee913afef40dffdc54e5bc (patch) | |
tree | e921bba840c3ccad30acdc10a48b92cd04b36b44 /contrib | |
parent | Add note on quoting to swaymsg manpage (diff) | |
download | sway-c65cd1cffa5a791202ee913afef40dffdc54e5bc.tar.gz sway-c65cd1cffa5a791202ee913afef40dffdc54e5bc.tar.zst sway-c65cd1cffa5a791202ee913afef40dffdc54e5bc.zip |
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.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/grimshot | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/grimshot b/contrib/grimshot index 4ee8d902..461a5eef 100755 --- a/contrib/grimshot +++ b/contrib/grimshot | |||
@@ -111,6 +111,10 @@ if [ "$ACTION" = "check" ] ; then | |||
111 | exit | 111 | exit |
112 | elif [ "$SUBJECT" = "area" ] ; then | 112 | elif [ "$SUBJECT" = "area" ] ; then |
113 | GEOM=$(slurp -d) | 113 | GEOM=$(slurp -d) |
114 | # Check if user exited slurp without selecting the area | ||
115 | if [ -z "$GEOM" ]; then | ||
116 | exit | ||
117 | fi | ||
114 | WHAT="Area" | 118 | WHAT="Area" |
115 | elif [ "$SUBJECT" = "active" ] ; then | 119 | elif [ "$SUBJECT" = "active" ] ; then |
116 | FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') | 120 | FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') |
@@ -126,6 +130,10 @@ elif [ "$SUBJECT" = "output" ] ; then | |||
126 | WHAT="$OUTPUT" | 130 | WHAT="$OUTPUT" |
127 | elif [ "$SUBJECT" = "window" ] ; then | 131 | elif [ "$SUBJECT" = "window" ] ; then |
128 | GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) | 132 | GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) |
133 | # Check if user exited slurp without selecting the area | ||
134 | if [ -z "$GEOM" ]; then | ||
135 | exit | ||
136 | fi | ||
129 | WHAT="Window" | 137 | WHAT="Window" |
130 | else | 138 | else |
131 | die "Unknown subject to take a screen shot from" "$SUBJECT" | 139 | die "Unknown subject to take a screen shot from" "$SUBJECT" |