Gimp-Forum.net
Setting a default directory to save files - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Tutorials and tips (https://www.gimp-forum.net/Forum-Tutorials-and-tips)
+--- Thread: Setting a default directory to save files (/Thread-Setting-a-default-directory-to-save-files)



Setting a default directory to save files - Ofnuts - 12-07-2025

You will have noticed that Gimp is hell-bent into saving everything by default in your Documents folder. It's no completely Gimp faults, it is the behavior of the GTK file dialog thayt Gimp uses.

The simple but incomplete solution is to add your favorite folder(s) to the Bookmarks panel on the left.

But you can also make Gimp use any directory by making it think it is your Documents folder.
  • The FreeDesktop standard defines several directories:  DESKTOP, DOWNLOAD, TEMPLATES, PUBLICSHARE, DOCUMENTS, MUSIC, PICTURES, VIDEOS
  • A configuration file called user-dirs.dirs can be used to define what actual directory is used for these symbolic directories. This is typically used to give language-dependent names. 
  • user-dirs.dirs is normally in ~/.config but you can tell the desktop code to use a different one by setting XDG_CONFIG_HOME environment variable to a directory that contains another version of user-dirs.dirs
  • You update the file with the xdg-user-dirs-update command, and you can check it use the xdg-user-dir command. These two commands will of course check the XDG_CONFIG_HOME environment variable.
So, all that is needed is to prepare a user-dirs.dirs pointing to the required directory, and set the XDG_CONFIG_HOME environment variable to point  to the alternate user-dirs.dirs directory in a script before calling Gimp.

So for instance, setting your destination directory to ~/tmp:

Do once:
Code:
export XDG_CONFIG_HOME=~/tmp/               # directory for user-dirs file, and your Gimp files
xdg-user-dirs-update --set DOCUMENTS ~/tmp  # Creates/updates the user-dirs file


Before calling Gimp (so create/modify script):

Code:
export XDG_CONFIG_HOME=~/tmp/  # tell FreeDesktop where to look for directories definition
gimp                           # start Gimp (can also be "exec gimp" to get rid of one level of shell)

The exemple above keeps the user-dirs.dir file and the Gimp files in the same directory but using different directories is left as an exercise for the reader.

If any Windows or OSX users are reading this, I wonder if this applies in other OS as well. If you are missing the xdg-user-dirs-update command, user-dirs.dirs is a plain text file and it looks like this:


# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
#
XDG_DOCUMENTS_DIR="$HOME/tmp"