summaryrefslogtreecommitdiff
path: root/scrshot
diff options
context:
space:
mode:
Diffstat (limited to 'scrshot')
-rwxr-xr-xscrshot50
1 files changed, 50 insertions, 0 deletions
diff --git a/scrshot b/scrshot
new file mode 100755
index 0000000..e270320
--- /dev/null
+++ b/scrshot
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+output_text () {
+ notify-send "$1" "$2"
+ printf "$2\n"
+}
+
+while getopts "hwxd:s:o:" o; do case "${o}" in
+ w)
+ DMENU="bemenu"
+ SCRSH="grim"
+ ;;
+ x)
+ DMENU="dmenu"
+ SCRSH="maim"
+ ;;
+ d) DARG="$OPTARG $DARG" ;;
+ s) SARG="$OPTARG $SARG" ;;
+ o) FILENAME="$OPTARG" ;;
+esac done
+
+if [ -z "$DMENU" ]; then
+ if [ -n "$WAYLAND_DISPLAY" ]; then
+ DMENU="bemenu"
+ SCRSH="grim"
+ elif [ -n "$DISPLAY" ]; then
+ DMENU="dmenu"
+ SCRSH="maim"
+ else
+ output_text "Stuck" "Can't tell if Wayland or X, what gives?"
+ exit 1
+ fi
+fi
+
+TEMPNAME="$(mktemp -u | xargs basename)"
+TEMPFILE="${TEMPNAME#tmp.}.png"
+
+"$SCRSH" $SARG "$TEMPFILE"
+
+if [ -z "$FILENAME" ]; then
+ FILENAME="$(echo "$TEMPFILE" | $DMENU $DARGS -p "What to name the file?")"
+ if [ -z "$FILENAME" ]; then
+ rm -rf "$TEMPFILE"
+ output_text "Deleted" "No filename selected, file deleted!"
+ exit
+ fi
+fi
+
+mv "$TEMPFILE" "$FILENAME"
+