summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Cyril Levis <cyril@levis.name>2020-01-27 23:44:38 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2020-02-04 23:52:08 +0100
commit0f975805525e6e08ff761b756141294c39d21131 (patch)
tree4e677760dbf44ecc2fd1b1b1d198df52b896fa9c /contrib
parentfix typo (diff)
downloadsway-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-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}
23FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')} 23FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')}
24if [ "$ACTION" = "usage" ] ; then 24if [ "$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() {
62takeScreenshot() { 62takeScreenshot() {
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
90elif [ "$SUBJECT" = "screen" ] ; then 93elif [ "$SUBJECT" = "screen" ] ; then
91 GEOM="" 94 GEOM=""
92 WHAT="Screen" 95 WHAT="Screen"
96elif [ "$SUBJECT" = "focused_screen" ] ; then
97 GEOM=""
98 SCREEN=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name')
99 WHAT="Focused screen $SCREEN"
93else 100else
94 die "Unknown subject to take a screen shot from" "$SUBJECT" 101 die "Unknown subject to take a screen shot from" "$SUBJECT"
95fi 102fi
96 103
97if [ "$ACTION" = "copy" ] ; then 104if [ "$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"
103else 110else
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"