summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2022-12-02 18:32:42 +0100
committerRobert Günzler <r@gnzler.io>2022-12-02 18:34:19 +0100
commitb60578d9cedfba64a602e8f51bf9e8ef59561f6b (patch)
tree56f3385a770977a622193ba7b49be6c209a1b53d /bin
parent2dc64c509a5292bd4f0ec4ac11dae4ec5e8c6525 (diff)
bin/grimshot: make it work without xdg-user-dir
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grimshot24
1 files changed, 14 insertions, 10 deletions
diff --git a/bin/grimshot b/bin/grimshot
index af7bcd1..de01976 100755
--- a/bin/grimshot
+++ b/bin/grimshot
@@ -29,15 +29,15 @@ _silence_notifications() {
 
 ACTION=${1:-usage}
 SUBJECT=${2:-screen}
-FILE=${3:-$(xdg-user-dir PICTURES)/screenshots/$(now).png}
+FILE=${3:-${HOME}/Pictures/screenshots/$(now).png}
 case "$ACTION" in
-	usage | help | -h | --help)
-		echo "Usage:"
-		echo "  grimshot copy|save|rec win|screen|area|output [FILE]"
-		echo "Troubleshoot:"
-		echo "  grimshot check"
-		exit
-		;;
+usage | help | -h | --help)
+	echo "Usage:"
+	echo "  grimshot copy|save|rec win|screen|area|output [FILE]"
+	echo "Troubleshoot:"
+	echo "  grimshot check"
+	exit
+	;;
 esac
 
 notify() {
@@ -134,6 +134,10 @@ else
 	die "Unknown subject to take a screen shot from" "$SUBJECT"
 fi
 
+if [ ! "$ACTION" = "copy" ]; then
+	mkdir -p "$(dirname "${FILE}")"
+fi
+
 if [ "$ACTION" = "copy" ]; then
 	TMP=$(mktemp) || die "Unable to create temp file: is mktemp installed?"
 	takeScreenshot "$TMP" "$GEOM" "$OUTPUT"
@@ -151,8 +155,8 @@ elif [ "$ACTION" = "save" ]; then
 		notifyError "Error taking screenshot with grim"
 	fi
 elif [ "$ACTION" = "rec" ]; then
-	echo "$FILE" | awk '/png$/{exit 0}' \
-		&& FILE=$(xdg-user-dir VIDEOS)/grimshot/$(now).mp4
+	echo "$FILE" | awk '/png$/{exit 0}' &&
+		FILE=$(xdg-user-dir VIDEOS)/grimshot/$(now).mp4
 	# create dir if not exists
 	[ -d "$(dirname "$FILE")" ] || mkdir -p "$(dirname "$FILE")"
 	recordScreen "$FILE" "$GEOM" "$OUTPUT"