GNOME Bugzilla – Bug 672833
screenshot: fails to save the file if XDG picture dir does not exist
Last modified: 2020-11-26 16:20:42 UTC
I changed XDG_PICTURES_DIR today. To a new directory that did not exist. Then I used GNOME Shell built in screenshot magic. The file was not saved, and no warning was provided. Creating the directory allowed screenshots to be saved.
(In reply to comment #0) > Then I used GNOME Shell built in screenshot magic. Do you mean the DBus method? Or did you rather use gnome-screenshot (either directly or via the printScreen shortcut)? > The file was not saved, and no warning was provided. If you went through gnome-screenshot, this clearly is a bug - IMO the directory should be created if it doesn't exist yet. I'm not that sure though whether we should expect callers to take care of that or whether we should do it ourselves in the shell. Cosimo, what do you think? Should we move the issue to gnome-screenshot?
(In reply to comment #1) > If you went through gnome-screenshot, this clearly is a bug - IMO the directory > should be created if it doesn't exist yet. I'm not that sure though whether we > should expect callers to take care of that or whether we should do it ourselves > in the shell. > > Cosimo, what do you think? Should we move the issue to gnome-screenshot? Yes, gnome-screenshot doesn't handle the case where XDG_PICTURES_DIR is missing.
Oh I thought the shell had its own backend for this. Well, I hit this by using the keyboard shortcut set in the Keyboard panel of control-center.
(In reply to comment #3) > Oh I thought the shell had its own backend for this. > > Well, I hit this by using the keyboard shortcut set in the Keyboard panel of > control-center. Yeah, it's complicated :) The keyboard shortcut is handled by gnome-settings-daemon, which calls gnome-screenshot, which uses a DBus method exported by the shell ... (In reply to comment #2) > (In reply to comment #1) > > Cosimo, what do you think? Should we move the issue to gnome-screenshot? > > Yes, gnome-screenshot doesn't handle the case where XDG_PICTURES_DIR is > missing. Right, and neither do gnome-shell or cairo (the actual file ends up being written by cairo_surface_write_to_png), so it's really a question of which layer is supposed to handle directory creation :)
(In reply to comment #4) > Right, and neither do gnome-shell or cairo (the actual file ends up being > written by cairo_surface_write_to_png), so it's really a question of which > layer is supposed to handle directory creation :) I think it's right to ensure the path exists at gnome-screenshot's level. I have a patch for this, just need to test it properly.
If it were still showing the useful dialog — like before — this wouldn’t be a problem.
I now pushed a fix for this to git master and gnome-3-4.
*** Bug 674616 has been marked as a duplicate of this bug. ***