jasonaowen / capture-workspace

What are you doing all day?
GNU General Public License v3.0
10 stars 0 forks source link

scrot appends filename numbering suffix #1

Open zormit opened 3 years ago

zormit commented 3 years ago

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.

jasonaowen commented 3 years ago

Interesting! Thanks for the report, @zormit - also hi, good to hear from you! :blue_heart:

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!

jasonaowen commented 3 years ago

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).