aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Hugo Osvaldo Barrera <hugo@barrera.io>2020-05-01 11:45:39 +0200
committerLibravatar Drew DeVault <sir@cmpwn.com>2020-05-05 20:18:19 +0200
commitb10b6b552b81baae8d6e39c2401815964ea4a542 (patch)
tree78b8293db9fdc8b4138dac744507fb10da51dfe4 /contrib
parentgrimshot: Allow manually picking a window (diff)
downloadsway-b10b6b552b81baae8d6e39c2401815964ea4a542.tar.gz
sway-b10b6b552b81baae8d6e39c2401815964ea4a542.tar.zst
sway-b10b6b552b81baae8d6e39c2401815964ea4a542.zip
grimshot: Add a separate flag for notifications
Make notifications a separate flag. Personally, I trigger grimshot myself most of the time (via sway bindsym) rather than by some external means, so I don't need to be notified of it happening. However, keep a flag with this functionality there for those scenarios there it's necessary to inform the user. Also print the file location when saving the screenshot.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/grimshot22
1 files changed, 18 insertions, 4 deletions
diff --git a/contrib/grimshot b/contrib/grimshot
index 154e4a9f..ed32334b 100755
--- a/contrib/grimshot
+++ b/contrib/grimshot
@@ -26,13 +26,20 @@ getTargetDirectory() {
26 echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}} 26 echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}
27} 27}
28 28
29if [ $1 == "--notify" ]; then
30 NOTIFY=yes
31 shift 1
32else
33 NOTIFY=no
34fi
35
29ACTION=${1:-usage} 36ACTION=${1:-usage}
30SUBJECT=${2:-screen} 37SUBJECT=${2:-screen}
31FILE=${3:-$(getTargetDirectory)/$(date -Ins).png} 38FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
32 39
33if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then 40if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
34 echo "Usage:" 41 echo "Usage:"
35 echo " grimshot (copy|save) [active|screen|output|area|window] [FILE]" 42 echo " grimshot [--notify] (copy|save) [active|screen|output|area|window] [FILE]"
36 echo " grimshot check" 43 echo " grimshot check"
37 echo " grimshot usage" 44 echo " grimshot usage"
38 echo "" 45 echo ""
@@ -55,14 +62,20 @@ notify() {
55 notify-send -t 3000 -a grimshot "$@" 62 notify-send -t 3000 -a grimshot "$@"
56} 63}
57notifyOk() { 64notifyOk() {
65 [ $NOTIFY = "no" ] && return
66
58 TITLE=${2:-"Screenshot"} 67 TITLE=${2:-"Screenshot"}
59 MESSAGE=${1:-"OK"} 68 MESSAGE=${1:-"OK"}
60 notify "$TITLE" "$MESSAGE" 69 notify "$TITLE" "$MESSAGE"
61} 70}
62notifyError() { 71notifyError() {
63 TITLE=${2:-"Screenshot"} 72 if [ $NOTIFY = "yes" ]; then
64 MESSAGE=${1:-"Error taking screenshot with grim"} 73 TITLE=${2:-"Screenshot"}
65 notify -u critical "$TITLE" "$MESSAGE" 74 MESSAGE=${1:-"Error taking screenshot with grim"}
75 notify -u critical "$TITLE" "$MESSAGE"
76 else
77 echo $1
78 fi
66} 79}
67 80
68die() { 81die() {
@@ -137,6 +150,7 @@ else
137 TITLE="Screenshot of $SUBJECT" 150 TITLE="Screenshot of $SUBJECT"
138 MESSAGE=$(basename "$FILE") 151 MESSAGE=$(basename "$FILE")
139 notifyOk "$MESSAGE" "$TITLE" 152 notifyOk "$MESSAGE" "$TITLE"
153 echo $FILE
140 else 154 else
141 notifyError "Error taking screenshot with grim" 155 notifyError "Error taking screenshot with grim"
142 fi 156 fi