screenshot: Fall back to home if Pictures directory is not available

GLib.get_user_special_dir() returns null if user directories are
disabled. Instead of failing silently, fall back to saving screenshots
in $HOME/Screenshots in that case

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5549

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2327>
This commit is contained in:
Sam Uong 2022-06-06 10:45:25 +00:00 committed by Florian Müllner
parent 97563cc4ac
commit ea60bf4bc7

View File

@ -2064,7 +2064,7 @@ function _storeScreenshot(bytes, pixbuf) {
if (!disableSaveToDisk) { if (!disableSaveToDisk) {
const dir = Gio.File.new_for_path(GLib.build_filenamev([ const dir = Gio.File.new_for_path(GLib.build_filenamev([
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES), GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) || GLib.get_home_dir(),
// Translators: name of the folder under ~/Pictures for screenshots. // Translators: name of the folder under ~/Pictures for screenshots.
_('Screenshots'), _('Screenshots'),
])); ]));