Store screenshots to the org.gnome.gnome-screenshot auto-save-directory directory, if defined

Bug #1818905 reported by Michael Aaron Murphy
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-shell (Ubuntu)
Invalid
Wishlist
Michael Aaron Murphy

Bug Description

When the `PrintScrn` key is pressed in GNOME Shell, it takes a screenshot and writes it to `$HOME/Pictures`, or otherwise falling back to `$HOME` if that directory is not found. The `gnome-screenshot` tool does a similar action, but also checks for the existence of the `auto-save-directory` gsetting in `org.gnome.gnome-screenshot`. This will allow GNOME Shell to also use that key, and store screenshots in this location when found.

### Implementation Note

I added a `CowPtr` type to make it possible for the `get_screenshot_directory()` function to return a `gchar*` which is either owned or borrowed, and to free a value when it is owned. `g_get_user_special_dir ()` and `g_get_home_dir ()` return `gchar*` values which are owned by GLib, and must not be freed, but `g_settings_get_string` is owned, and must be freed.

Alternatively, I could `g_strdup()` the values to copy them onto the heap.

### Testing

1. Before applying the patch, take a screenshot with the PrintScrn key.
2. A screenshot should now be stored in `$HOME/Pictures`.
3. Create the new screenshot directory, and set the value for gnome-screenshot:
```sh
mkdir $HOME/Screenshots
gsettings set org.gnome.gnome-screenshot auto-save-directory $HOME/Screenshots
```
4. Take the screenshot again, and notice that it stores in `$HOME/Pictures` instead of `$HOME/Screenshots`
5. Apply the patch, and restart `gnome-shell`, then take the screenshot again
6. The screenshot should be written in `$HOME/Screenshots` instead of `$HOME/Pictures`.
7. Delete the gsettings value, and try again, to see that it returns to storing screenshots in `$HOME/Pictures`
```sh
gsettings reset org.gnome.gnome-screenshot auto-save-directory
```

Tags: patch
Revision history for this message
Michael Aaron Murphy (mmstick76) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug report and work, the right place to suggest code changes is upstream though, https://gitlab.gnome.org/GNOME/gnome-shell/issues
Can you merge propose your changes there?

Changed in gnome-shell (Ubuntu):
importance: Undecided → Wishlist
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "screenshot_dir.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Michael,

Please also propose your change here:

  https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests

Changed in gnome-shell (Ubuntu):
status: New → Incomplete
status: Incomplete → New
status: New → In Progress
assignee: nobody → Michael Aaron Murphy (mmstick76)
Revision history for this message
Michael Aaron Murphy (mmstick76) wrote :

Updating this to state that GNOME has yet to make a decision on how to approach this, but whatever decision they make will not consist of sharing an application-specific variable with GDM.

They seem to be hinting that they will create a global variable that applications can use, but they've yet to make a decisions on where or how they want it implemented. Still waiting for feedback on the implementation specifics.

Changed in gnome-shell (Ubuntu):
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.