mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
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 c65cd1cffa
)
This commit is contained in:
parent
105c69d431
commit
a314deeaa3
|
@ -111,6 +111,10 @@ if [ "$ACTION" = "check" ] ; then
|
||||||
exit
|
exit
|
||||||
elif [ "$SUBJECT" = "area" ] ; then
|
elif [ "$SUBJECT" = "area" ] ; then
|
||||||
GEOM=$(slurp -d)
|
GEOM=$(slurp -d)
|
||||||
|
# Check if user exited slurp without selecting the area
|
||||||
|
if [ -z "$GEOM" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
WHAT="Area"
|
WHAT="Area"
|
||||||
elif [ "$SUBJECT" = "active" ] ; then
|
elif [ "$SUBJECT" = "active" ] ; then
|
||||||
FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)')
|
FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)')
|
||||||
|
@ -126,6 +130,10 @@ elif [ "$SUBJECT" = "output" ] ; then
|
||||||
WHAT="$OUTPUT"
|
WHAT="$OUTPUT"
|
||||||
elif [ "$SUBJECT" = "window" ] ; then
|
elif [ "$SUBJECT" = "window" ] ; then
|
||||||
GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
|
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"
|
WHAT="Window"
|
||||||
else
|
else
|
||||||
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
||||||
|
|
Loading…
Reference in a new issue