Skip to content

Commit

Permalink
Add savecopy command to grimshot
Browse files Browse the repository at this point in the history
  • Loading branch information
laurelmay authored and OctopusET committed Jan 20, 2024
1 parent 5f4d613 commit 2a132b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion grimshot
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ACTION=${1:-usage}
SUBJECT=${2:-screen}
FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}

if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "savecopy" ] && [ "$ACTION" != "check" ]; then
echo "Usage:"
echo " grimshot [--notify] [--cursor] [--wait N] (copy|save) [active|screen|output|area|window|anything] [FILE|-]"
echo " grimshot check"
Expand All @@ -63,6 +63,7 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check"
echo "Commands:"
echo " copy: Copy the screenshot data into the clipboard."
echo " save: Save the screenshot to a regular file or '-' to pipe to STDOUT."
echo " savecopy: Save the screenshot to a regular file and copy the data into the clipboard."
echo " check: Verify if required tools are installed and exit."
echo " usage: Show this message and exit."
echo ""
Expand Down Expand Up @@ -184,6 +185,10 @@ else
MESSAGE=$(basename "$FILE")
notifyOk "$MESSAGE" "$TITLE"
echo "$FILE"
if [ "$ACTION" = "savecopy" ]; then
wl-copy --type image/png < "$FILE" || die "Clipboard error"
notifyOk "$WHAT copied to buffer"
fi
else
notifyError "Error taking screenshot with grim"
fi
Expand Down
10 changes: 8 additions & 2 deletions grimshot.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.nh
.ad l
.\" Begin generated content:
.TH "grimshot" "1" "2023-08-24"
.TH "grimshot" "1" "2024-01-01"
.P
.SH NAME
.P
Expand Down Expand Up @@ -51,6 +51,12 @@ Set FILE to '\&-'\& to pipe the output to STDOUT.\&
Copy the screenshot data (as image/png) into the clipboard.\&
.P
.RE
\fB\fRsavecopy\fB\fR
.RS 4
Save the screenshot into a regular file (see \fIsave\fR documentation) and
copy the screenshot data into the clipboard (see \fIcopy\fR documentation).\&
.P
.RE
.SH DESCRIPTION
.P
Grimshot is an easy-to-use screenshot utility for sway.\& It provides a
Expand Down Expand Up @@ -116,7 +122,7 @@ using click and drag).\&
.SH OUTPUT
.P
Grimshot will print the filename of the captured screenshot to stdout if called
with the \fIsave\fR subcommand.\&
with the \fIsave\fR or \fIsavecopy\fR subcommands.\&
.P
.SH SEE ALSO
.P
Expand Down
6 changes: 5 additions & 1 deletion grimshot.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ grimshot - a helper for screenshots within sway
*copy*
Copy the screenshot data (as image/png) into the clipboard.

**savecopy**
Save the screenshot into a regular file (see _save_ documentation) and
copy the screenshot data into the clipboard (see _copy_ documentation).

# DESCRIPTION

Grimshot is an easy-to-use screenshot utility for sway. It provides a
Expand Down Expand Up @@ -83,7 +87,7 @@ _anything_
# OUTPUT

Grimshot will print the filename of the captured screenshot to stdout if called
with the _save_ subcommand.
with the _save_ or _savecopy_ subcommands.

# SEE ALSO

Expand Down

0 comments on commit 2a132b8

Please sign in to comment.