mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
Add selection subject option to grimshot
This enables selecting a window, output, or area within one invocation. - Drag for an area - Click on a window to select it - Click outside of all windows (e.g. in gaps or on the statusbar) to select the output
This commit is contained in:
parent
8f036b6f78
commit
49545189ac
3 changed files with 22 additions and 2 deletions
|
|
@ -32,7 +32,7 @@ FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
|
||||||
|
|
||||||
if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
|
if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " grimshot [--notify] (copy|save) [active|screen|output|area|window] [FILE|-]"
|
echo " grimshot [--notify] (copy|save) [active|screen|output|area|window|selection] [FILE|-]"
|
||||||
echo " grimshot check"
|
echo " grimshot check"
|
||||||
echo " grimshot usage"
|
echo " grimshot usage"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -48,6 +48,7 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check"
|
||||||
echo " output: Currently active output."
|
echo " output: Currently active output."
|
||||||
echo " area: Manually select a region."
|
echo " area: Manually select a region."
|
||||||
echo " window: Manually select a window."
|
echo " window: Manually select a window."
|
||||||
|
echo " selection: Manually select an area, window, or output."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -135,6 +136,13 @@ elif [ "$SUBJECT" = "window" ] ; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
WHAT="Window"
|
WHAT="Window"
|
||||||
|
elif [ "$SUBJECT" = "selection" ] ; then
|
||||||
|
GEOM=$(swaymsg -t get_tree | jq -r '.. | select((.pid? and .visible?) or (.type == "output" and .active)) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
|
||||||
|
# Check if user exited slurp without selecting the area
|
||||||
|
if [ -z "$GEOM" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
WHAT="Selection"
|
||||||
else
|
else
|
||||||
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
.nh
|
.nh
|
||||||
.ad l
|
.ad l
|
||||||
.\" Begin generated content:
|
.\" Begin generated content:
|
||||||
.TH "grimshot" "1" "2021-02-23"
|
.TH "grimshot" "1" "2021-05-20"
|
||||||
.P
|
.P
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.P
|
.P
|
||||||
|
|
@ -94,6 +94,13 @@ captures it.\&
|
||||||
Captures the currently active output.\&
|
Captures the currently active output.\&
|
||||||
.P
|
.P
|
||||||
.RE
|
.RE
|
||||||
|
\fIselection\fR
|
||||||
|
.RS 4
|
||||||
|
Allows manually selection a single window (by clicking on it), an output (by
|
||||||
|
clicking outside of all windows, e.\&g.\& on the status bar), or an area (by
|
||||||
|
using click and drag).\&
|
||||||
|
.P
|
||||||
|
.RE
|
||||||
.SH OUTPUT
|
.SH OUTPUT
|
||||||
.P
|
.P
|
||||||
Grimshot will print the filename of the captured screenshot to stdout if called
|
Grimshot will print the filename of the captured screenshot to stdout if called
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,11 @@ _window_
|
||||||
_output_
|
_output_
|
||||||
Captures the currently active output.
|
Captures the currently active output.
|
||||||
|
|
||||||
|
_selection_
|
||||||
|
Allows manually selection a single window (by clicking on it), an output (by
|
||||||
|
clicking outside of all windows, e.g. on the status bar), or an area (by
|
||||||
|
using click and drag).
|
||||||
|
|
||||||
# OUTPUT
|
# OUTPUT
|
||||||
|
|
||||||
Grimshot will print the filename of the captured screenshot to stdout if called
|
Grimshot will print the filename of the captured screenshot to stdout if called
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue