From 4c706182e818779258c0e74ecddec13090cf2f71 Mon Sep 17 00:00:00 2001 From: Levi van der Maas Date: Mon, 5 Oct 2026 14:03:15 +0200 Subject: [PATCH] Grimblast: When saving screenshot, create parent dir if it doesn't exist Previously, grimblast would fail to save the screenshot if the target file location's parent dir did not exist yet (but it would still notify you that it succesfully saved). --- CHANGELOG.md | 4 ++++ grimblast/grimblast | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4a342c..3acf389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 2026-10-05 + +grimblast: create parent dirs when saving to file instead of failing when they don't exist. + ### 2026-08-21 grimblast: update layerrule to lua syntax diff --git a/grimblast/grimblast b/grimblast/grimblast index 61c9561..8a72eff 100755 --- a/grimblast/grimblast +++ b/grimblast/grimblast @@ -153,6 +153,9 @@ grimblast::check() { # The actual grim command used is printed to stderr screenshot() { local file="$1" output="$2" + if [[ -n "$file" ]]; then + mkdir -p "$(dirname "$file")" + fi xargs --verbose grim <<<"${CURSOR:+-c} ${SCALE:+-s \"$SCALE\"} -t \"$FILETYPE\" ${output:+-o \"$output\"} ${GEOM:+-g \"$GEOM\"} ${WINDOW:+-T \"$WINDOW\"} \"$file\"" } @@ -292,6 +295,7 @@ copysave() { screenshot - "$OUTPUT" | tee >(wl-copy --type "$(get-mime-type)") || die "Clipboard error" notify::ok "$WHAT copied to buffer and piped to stdout" else + mkdir -p "$(dirname "$file")" screenshot - "$OUTPUT" | tee "$file" | wl-copy --type "$(get-mime-type)" || die "Clipboard error" title="Screenshot of $WHAT" message="$WHAT copied to buffer and saved to $file"