Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add savecopy command to grimshot #21

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.\&
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it's rendered like save or savecopy in man. I don't think it's an error. Just curiosity. Anyways, LGTM.

.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