mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
feat: grimshot supports save and copy
Adds new action savecopy which saves then copies Fixes: 7116
This commit is contained in:
parent
e40eb338b9
commit
4ad568662d
1 changed files with 21 additions and 14 deletions
|
|
@ -44,7 +44,7 @@ ACTION=${1:-usage}
|
||||||
SUBJECT=${2:-screen}
|
SUBJECT=${2:-screen}
|
||||||
FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
|
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 "Usage:"
|
||||||
echo " grimshot [--notify] [--cursor] (copy|save) [active|screen|output|area|window] [FILE|-]"
|
echo " grimshot [--notify] [--cursor] (copy|save) [active|screen|output|area|window] [FILE|-]"
|
||||||
echo " grimshot check"
|
echo " grimshot check"
|
||||||
|
|
@ -53,6 +53,7 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check"
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " copy: Copy the screenshot data into the clipboard."
|
echo " copy: Copy the screenshot data into the clipboard."
|
||||||
echo " save: Save the screenshot to a regular file or '-' to pipe to STDOUT."
|
echo " save: Save the screenshot to a regular file or '-' to pipe to STDOUT."
|
||||||
|
echo " savecopy: Saves the screenshot to a regular file and copies the data into the clipboard."
|
||||||
echo " check: Verify if required tools are installed and exit."
|
echo " check: Verify if required tools are installed and exit."
|
||||||
echo " usage: Show this message and exit."
|
echo " usage: Show this message and exit."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -153,16 +154,22 @@ else
|
||||||
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
die "Unknown subject to take a screen shot from" "$SUBJECT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ACTION" = "copy" ] ; then
|
case "$ACTION" in
|
||||||
takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error"
|
copy)
|
||||||
notifyOk "$WHAT copied to buffer"
|
takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error";
|
||||||
else
|
notifyOk "$WHAT copied to buffer";;
|
||||||
|
save*)
|
||||||
if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then
|
if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then
|
||||||
|
if [ "$ACTION" = "savecopy" ]; then
|
||||||
|
wl-copy --type image/png < "$FILE" || die "Clipboard error"
|
||||||
|
fi
|
||||||
TITLE="Screenshot of $SUBJECT"
|
TITLE="Screenshot of $SUBJECT"
|
||||||
MESSAGE=$(basename "$FILE")
|
MESSAGE=$(basename "$FILE")
|
||||||
notifyOk "$MESSAGE" "$TITLE"
|
notifyOk "$MESSAGE" "$TITLE"
|
||||||
echo "$FILE"
|
echo "$FILE"
|
||||||
else
|
else
|
||||||
notifyError "Error taking screenshot with grim"
|
notifyError "Error taking screenshot with grim"
|
||||||
fi
|
fi;;
|
||||||
fi
|
*)
|
||||||
|
die "Unexpected action: $ACTION"
|
||||||
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue