scrot appends filename numbering suffix
zormit opened this issue · 2 comments
Not sure if this is for every setup, so I'm creating an issue instead of a PR:
I had to change the following to make it work for me:
diff --git a/capture-workspace b/capture-workspace
index 928ddfb..f03a176 100755
--- a/capture-workspace
+++ b/capture-workspace
@@ -11,6 +11,6 @@ jq -nS \
cmd: \"$(ps h -o cmd -q $(xdotool getactivewindow getwindowpid))\",
window_name: \"$(xdotool getactivewindow getwindowname)\" }" \
> ~/Pictures/Screenshots/${DATE}/"${DATETIME}".json
-scrot --multidisp --silent ${TEMPFILE}
+scrot --multidisp --silent --overwrite ${TEMPFILE}
pngcrush -q ${TEMPFILE} ~/Pictures/Screenshots/${DATE}/"${DATETIME}".png
rm ${TEMPFILE}
otherwise, pngcrush
did not find ${TEMPFILE}
, as scrot
modified the filename by adding a suffix.
Interesting! Thanks for the report, @zormit - also hi, good to hear from you! 💙
According to the changelog, scrot added the --overwrite
argument in the 1.0 release. The packaged versions distributed in Ubuntu 20.04 and Debian Buster include this change; previous OS versions packaged older versions of scrot without --overwrite
. That's why I hadn't noticed it before, then!
As part of the PR introducing --overwrite
, the default behavior was changed from silently overwriting to silently using another name; that's a slightly unfortunate change, but it was clearly communicated by incrementing the major version number.
Fortunately, this exact use-case is addressed in a comment on a follow-up issue! The backwards-compatible fix, then, should be to add --dry-run
to the call to mktemp
- this should work on both the old and new versions.
@zormit, if you're interested, I'd love to see that in a pull request!
A small addendum: adding the --overwrite
argument to an old version causes additional output to be printed:
scrot: unrecognized option '--overwrite'
Which would mean an email every 5 minutes, assuming cron is set up to email output (which it does by default) and that the system has email set up (which is less common on desktops).