summaryrefslogtreecommitdiff
path: root/scrshot
diff options
context:
space:
mode:
Diffstat (limited to 'scrshot')
-rwxr-xr-xscrshot23
1 files changed, 17 insertions, 6 deletions
diff --git a/scrshot b/scrshot
index 8982b56..e400b8e 100755
--- a/scrshot
+++ b/scrshot
@@ -2,19 +2,30 @@
output_text () {
notify-send "$1" "$2"
- printf "$2\n"
+ printf "%s\n" "$2"
}
-while getopts "hwxd:s:o:" o; do case "${o}" in
+printhelp () {
+ printf "scrshot: takes a screenshot and saves to a filename.\n"
+ printf "\tw) force wayland backend\n"
+ printf "\tx) force x backend\n"
+ printf "\td X) provide X as arg to dmenu\n"
+ printf "\ts X) provide X as arg to screenshot util\n"
+ printf "\to X) save file to X\n"
+ exit 1
+}
+
+while getopts "wxd:s:o:" o; do case "${o}" in
w)
SCRSH="grim"
;;
x)
SCRSH="maim"
;;
- d) DARG="$OPTARG $DARG" ;;
- s) SARG="$OPTARG $SARG" ;;
+ d) DARG="$OPTARG" ;;
+ s) SARG="$OPTARG" ;;
o) FILENAME="$OPTARG" ;;
+ *) printhelp ;;
esac done
if [ -z "$SCRSH" ]; then
@@ -34,10 +45,10 @@ TEMPNAME="$(mktemp -u | xargs basename)"
TEMPFILE="${TEMPNAME#tmp.}.png"
sleep 0.1
-"$SCRSH" $SARG "$TEMPFILE"
+"$SCRSH" ${SARG:+"$SARG"} "$TEMPFILE"
if [ -z "$FILENAME" ]; then
- FILENAME="$(echo "$TEMPFILE" | dmenu $DARGS -p "What to name the file?")"
+ FILENAME="$(echo "$TEMPFILE" | dmenu ${DARG:+"$DARG"} -p "What to name the file?")"
if [ -z "$FILENAME" ]; then
rm -rf "$TEMPFILE"
output_text "Deleted" "No filename selected, file deleted!"