aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Levis <cyril@levis.name>2020-01-27 23:44:38 +0100
committerSimon Ser <contact@emersion.fr>2020-02-04 23:52:08 +0100
commit0f975805525e6e08ff761b756141294c39d21131 (patch)
tree4e677760dbf44ecc2fd1b1b1d198df52b896fa9c
parent84ea03109d5b4c84e4c183cbffeaaf4459cfdc3a (diff)
Add the possibility to capture only one screen if several screens are use.
-rwxr-xr-xcontrib/grimshot15
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/grimshot b/contrib/grimshot
index 8a253ce8..7757d6ce 100755
--- a/contrib/grimshot
+++ b/contrib/grimshot
@@ -23,7 +23,7 @@ SUBJECT=${2:-screen}
FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')}
if [ "$ACTION" = "usage" ] ; then
echo "Usage:"
- echo " grimshot copy|save win|screen|area [FILE]"
+ echo " grimshot copy|save win|screen|focused_screen|area [FILE]"
echo "Troubleshoot:"
echo " grimshot check"
exit
@@ -62,7 +62,10 @@ check() {
takeScreenshot() {
FILE=$1
GEOM=$2
- if [ -z "$GEOM" ]; then
+ SCREEN=$3
+ if [ ! -z "$SCREEN" ]; then
+ grim -o "$SCREEN" "$FILE" || die "Unable to invoke grim"
+ elif [ -z "$GEOM" ]; then
grim "$FILE" || die "Unable to invoke grim"
else
grim -g "$GEOM" "$FILE" || die "Unable to invoke grim"
@@ -90,18 +93,22 @@ elif [ "$SUBJECT" = "win" ] ; then
elif [ "$SUBJECT" = "screen" ] ; then
GEOM=""
WHAT="Screen"
+elif [ "$SUBJECT" = "focused_screen" ] ; then
+ GEOM=""
+ SCREEN=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name')
+ WHAT="Focused screen $SCREEN"
else
die "Unknown subject to take a screen shot from" "$SUBJECT"
fi
if [ "$ACTION" = "copy" ] ; then
TMP=$(mktemp) || die "Unable to create temp file: is mktemp installed?"
- takeScreenshot "$TMP" "$GEOM"
+ takeScreenshot "$TMP" "$GEOM" "$SCREEN"
wl-copy --type image/png < "$TMP" || die "Clipboard error"
rm "$TMP"
notifyOk "$WHAT copied to buffer"
else
- if takeScreenshot "$FILE" "$GEOM"; then
+ if takeScreenshot "$FILE" "$GEOM" "$SCREEN"; then
TITLE="Screenshot of $SUBJECT"
MESSAGE=$(basename "$FILE")
notifyOk "$MESSAGE" "$TITLE"