diff options
author | Hugo Osvaldo Barrera <hugo@barrera.io> | 2020-05-01 11:45:39 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-05-05 20:18:19 +0200 |
commit | b10b6b552b81baae8d6e39c2401815964ea4a542 (patch) | |
tree | 78b8293db9fdc8b4138dac744507fb10da51dfe4 | |
parent | grimshot: Allow manually picking a window (diff) | |
download | sway-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.
-rwxr-xr-x | contrib/grimshot | 22 |
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 | ||
29 | if [ $1 == "--notify" ]; then | ||
30 | NOTIFY=yes | ||
31 | shift 1 | ||
32 | else | ||
33 | NOTIFY=no | ||
34 | fi | ||
35 | |||
29 | ACTION=${1:-usage} | 36 | ACTION=${1:-usage} |
30 | SUBJECT=${2:-screen} | 37 | SUBJECT=${2:-screen} |
31 | FILE=${3:-$(getTargetDirectory)/$(date -Ins).png} | 38 | FILE=${3:-$(getTargetDirectory)/$(date -Ins).png} |
32 | 39 | ||
33 | if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then | 40 | if [ "$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 | } |
57 | notifyOk() { | 64 | notifyOk() { |
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 | } |
62 | notifyError() { | 71 | notifyError() { |
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 | ||
68 | die() { | 81 | die() { |
@@ -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 |