diff options
author | Cyril Levis <cyril@levis.name> | 2020-01-27 23:44:38 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-02-04 23:52:08 +0100 |
commit | 0f975805525e6e08ff761b756141294c39d21131 (patch) | |
tree | 4e677760dbf44ecc2fd1b1b1d198df52b896fa9c /contrib | |
parent | fix typo (diff) | |
download | sway-0f975805525e6e08ff761b756141294c39d21131.tar.gz sway-0f975805525e6e08ff761b756141294c39d21131.tar.zst sway-0f975805525e6e08ff761b756141294c39d21131.zip |
Add the possibility to capture only one screen if several screens are use.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/grimshot | 15 |
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} | |||
23 | FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')} | 23 | FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')} |
24 | if [ "$ACTION" = "usage" ] ; then | 24 | if [ "$ACTION" = "usage" ] ; then |
25 | echo "Usage:" | 25 | echo "Usage:" |
26 | echo " grimshot copy|save win|screen|area [FILE]" | 26 | echo " grimshot copy|save win|screen|focused_screen|area [FILE]" |
27 | echo "Troubleshoot:" | 27 | echo "Troubleshoot:" |
28 | echo " grimshot check" | 28 | echo " grimshot check" |
29 | exit | 29 | exit |
@@ -62,7 +62,10 @@ check() { | |||
62 | takeScreenshot() { | 62 | takeScreenshot() { |
63 | FILE=$1 | 63 | FILE=$1 |
64 | GEOM=$2 | 64 | GEOM=$2 |
65 | if [ -z "$GEOM" ]; then | 65 | SCREEN=$3 |
66 | if [ ! -z "$SCREEN" ]; then | ||
67 | grim -o "$SCREEN" "$FILE" || die "Unable to invoke grim" | ||
68 | elif [ -z "$GEOM" ]; then | ||
66 | grim "$FILE" || die "Unable to invoke grim" | 69 | grim "$FILE" || die "Unable to invoke grim" |
67 | else | 70 | else |
68 | grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" | 71 | grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" |
@@ -90,18 +93,22 @@ elif [ "$SUBJECT" = "win" ] ; then | |||
90 | elif [ "$SUBJECT" = "screen" ] ; then | 93 | elif [ "$SUBJECT" = "screen" ] ; then |
91 | GEOM="" | 94 | GEOM="" |
92 | WHAT="Screen" | 95 | WHAT="Screen" |
96 | elif [ "$SUBJECT" = "focused_screen" ] ; then | ||
97 | GEOM="" | ||
98 | SCREEN=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') | ||
99 | WHAT="Focused screen $SCREEN" | ||
93 | else | 100 | else |
94 | die "Unknown subject to take a screen shot from" "$SUBJECT" | 101 | die "Unknown subject to take a screen shot from" "$SUBJECT" |
95 | fi | 102 | fi |
96 | 103 | ||
97 | if [ "$ACTION" = "copy" ] ; then | 104 | if [ "$ACTION" = "copy" ] ; then |
98 | TMP=$(mktemp) || die "Unable to create temp file: is mktemp installed?" | 105 | TMP=$(mktemp) || die "Unable to create temp file: is mktemp installed?" |
99 | takeScreenshot "$TMP" "$GEOM" | 106 | takeScreenshot "$TMP" "$GEOM" "$SCREEN" |
100 | wl-copy --type image/png < "$TMP" || die "Clipboard error" | 107 | wl-copy --type image/png < "$TMP" || die "Clipboard error" |
101 | rm "$TMP" | 108 | rm "$TMP" |
102 | notifyOk "$WHAT copied to buffer" | 109 | notifyOk "$WHAT copied to buffer" |
103 | else | 110 | else |
104 | if takeScreenshot "$FILE" "$GEOM"; then | 111 | if takeScreenshot "$FILE" "$GEOM" "$SCREEN"; then |
105 | TITLE="Screenshot of $SUBJECT" | 112 | TITLE="Screenshot of $SUBJECT" |
106 | MESSAGE=$(basename "$FILE") | 113 | MESSAGE=$(basename "$FILE") |
107 | notifyOk "$MESSAGE" "$TITLE" | 114 | notifyOk "$MESSAGE" "$TITLE" |