aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/grimshot
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/grimshot')
-rwxr-xr-xcontrib/grimshot46
1 files changed, 30 insertions, 16 deletions
diff --git a/contrib/grimshot b/contrib/grimshot
index 4ce31f29..d42fe9d8 100755
--- a/contrib/grimshot
+++ b/contrib/grimshot
@@ -13,18 +13,32 @@
13## See `man 1 grimshot` or `grimshot usage` for further details. 13## See `man 1 grimshot` or `grimshot usage` for further details.
14 14
15getTargetDirectory() { 15getTargetDirectory() {
16 test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && \ 16 test -f "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs" && \
17 . ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs 17 . "${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs"
18 18
19 echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}} 19 echo "${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}"
20} 20}
21 21
22if [ "$1" = "--notify" ]; then 22NOTIFY=no
23 NOTIFY=yes 23CURSOR=
24 shift 1 24
25else 25while [ $# -gt 0 ]; do
26 NOTIFY=no 26 key="$1"
27fi 27
28 case $key in
29 -n|--notify)
30 NOTIFY=yes
31 shift # past argument
32 ;;
33 -c|--cursor)
34 CURSOR=yes
35 shift # past argument
36 ;;
37 *) # unknown option
38 break # done with parsing --flags
39 ;;
40 esac
41done
28 42
29ACTION=${1:-usage} 43ACTION=${1:-usage}
30SUBJECT=${2:-screen} 44SUBJECT=${2:-screen}
@@ -32,7 +46,7 @@ FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
32 46
33if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then 47if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
34 echo "Usage:" 48 echo "Usage:"
35 echo " grimshot [--notify] (copy|save) [active|screen|output|area|window] [FILE|-]" 49 echo " grimshot [--notify] [--cursor] (copy|save) [active|screen|output|area|window] [FILE|-]"
36 echo " grimshot check" 50 echo " grimshot check"
37 echo " grimshot usage" 51 echo " grimshot usage"
38 echo "" 52 echo ""
@@ -67,7 +81,7 @@ notifyError() {
67 MESSAGE=${1:-"Error taking screenshot with grim"} 81 MESSAGE=${1:-"Error taking screenshot with grim"}
68 notify -u critical "$TITLE" "$MESSAGE" 82 notify -u critical "$TITLE" "$MESSAGE"
69 else 83 else
70 echo $1 84 echo "$1"
71 fi 85 fi
72} 86}
73 87
@@ -91,12 +105,12 @@ takeScreenshot() {
91 FILE=$1 105 FILE=$1
92 GEOM=$2 106 GEOM=$2
93 OUTPUT=$3 107 OUTPUT=$3
94 if [ ! -z "$OUTPUT" ]; then 108 if [ -n "$OUTPUT" ]; then
95 grim -o "$OUTPUT" "$FILE" || die "Unable to invoke grim" 109 grim ${CURSOR:+-c} -o "$OUTPUT" "$FILE" || die "Unable to invoke grim"
96 elif [ -z "$GEOM" ]; then 110 elif [ -z "$GEOM" ]; then
97 grim "$FILE" || die "Unable to invoke grim" 111 grim ${CURSOR:+-c} "$FILE" || die "Unable to invoke grim"
98 else 112 else
99 grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" 113 grim ${CURSOR:+-c} -g "$GEOM" "$FILE" || die "Unable to invoke grim"
100 fi 114 fi
101} 115}
102 116
@@ -147,7 +161,7 @@ else
147 TITLE="Screenshot of $SUBJECT" 161 TITLE="Screenshot of $SUBJECT"
148 MESSAGE=$(basename "$FILE") 162 MESSAGE=$(basename "$FILE")
149 notifyOk "$MESSAGE" "$TITLE" 163 notifyOk "$MESSAGE" "$TITLE"
150 echo $FILE 164 echo "$FILE"
151 else 165 else
152 notifyError "Error taking screenshot with grim" 166 notifyError "Error taking screenshot with grim"
153 fi 167 fi