lxqt / screengrab

Crossplatform tool for fast making screenshots.
https://lxqt.github.io
GNU General Public License v2.0
71 stars 45 forks source link

Avoid File overwritten when autoSave=true #369

Open Bluey26 opened 1 month ago

Bluey26 commented 1 month ago
Expected Behavior

Screengrab should (in my opinion) have a way to 'detect' that the 'following' filename is already present, and write to the next one, even if the file was not created by screengrab

Current Behavior

When autoSave=true (Avoids the need to open a filedialog and save the file), the program writes the image to the file corresponding to the 'next one', but according to screengrab. What i think its happening is that screengrab 'stores' the last name or the last filename generated by screengrab(all the screengrab filenames?) and then uses the N+1 (where N is the last number) as filename. This causes problems at the moment (at least for me), because since ScreenGrab is not fully working in wayland session (i use a grim script), when i go back to X11 to screen or capture an image (screengrab working) the file overwrites a file already present and made by the grim script.

My grim script basically goes to the folder where all the screens are saved(is the same for ScreenGrab) and stores is following the same arguments for name and extension:

grim -t jpeg -q 100 -g "$(slurp)" screen$(ls screen* | wc -l).jpg && notify-send -a grim -i screengrab -t 2000 "Se ha guardado la captura"

This is just to have all the pictures sorted and organized, but it has the problem i describe ( i used to have 2 separated folders for each program, but that made me forgot where the screen i was looking for was located).

As you can see in the script line (its inside a .sh which is launched using labwc rc.xml, the script checks beforehand the numbers of the pictures (screen screen01 screen02 ,etc) and then uses the number of pictures as number for the file: if there are 2000 pictures (1999 is the last number , plus screen.jpg which does not have a number), the resulting screenshot would have the name screen2000.jpg

I know this is just a script and that it just works, and that ScreenGrab will work in the future for Wayland sessions too, but this would make me delete a lot of pictures or rename/move them to avoid overwriting.

Possible Solution

Detecting the filenames in the folder in another way, or having an option to do so, plus the current behavior

Steps to Reproduce (for bugs)
  1. taking a screenshoot using the grim script
  2. Login on x11 and taking a screenshoot with the same name-syntax and same directory
  3. the screenshoot taken with screengrab will overwrite the screenshot taken with the other program, if autoSave=true in the screengrab configuration.
Context

I enter from time to time to X11 and sometimes i need to take screenshots. I discovered that the screenshots where not at the end of the folder ( i have sorting by time of modification)

System Information
tsujan commented 1 month ago

In general, I agree that if an app "auto-saves" something, it shouldn't overwrite a file which hasn't been opened by it. Since Screengrab doesn't open files, it shouldn't overwrite any either.

Sorry, I didn't have time to read all of your comment. So, tell me if you meant something else — but please, concisely.

Bluey26 commented 1 month ago

Yes, in a short way, screengrab overwrites the files generated by another screenshot tool, grim, if i use the same name syntax and directory, which i find undesirable.

This happens with autosave=true should not when false because it will open filedialog