Skip to content

src/shell-screenshot.c: Fetch the screenshot directory from GSettings

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.

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:
mkdir $HOME/Screenshots
gsettings set org.gnome.gnome-screenshot auto-save-directory $HOME/Screenshots
  1. Take the screenshot again, and notice that it stores in $HOME/Pictures instead of $HOME/Screenshots
  2. Apply the patch, and restart gnome-shell, then take the screenshot again
  3. The screenshot should be written in $HOME/Screenshots instead of $HOME/Pictures.
  4. Delete the gsettings value, and try again, to see that it returns to storing screenshots in $HOME/Pictures
gsettings reset org.gnome.gnome-screenshot auto-save-directory
Edited by Michael Aaron Murphy

Merge request reports