<div dir="ltr">Hi all,<div><br></div><div>I'd like to propose an extension to the current xdg-user-dirs mechanism to make it possible to create application-specific subdirectories in user dirs, which are subject to the same translation rules applied to their parents.</div>
<div><br></div><div>Use cases:</div><div>* An application (e.g. a sound recorder) wants to save a file in a subdirectory of $XDG_MUSIC_DIR. Another sound recorder wants to save files in the same subdirectory, and doesn't want to worry about the translations for each language to be in sync.</div>
<div><br></div><div>* A photo booth application wants to save pictures to a webcam snaps subdirectory of $XDG_PICTURES_DIR. An "user properties" settings panel in the desktop environment allows to pick an avatar picture through a file chooser, which should default to the webcam snaps place.</div>
<div><br></div><div>There's a bunch of similar cases, which you can find in this bug [1] where this message originates from.</div><div><br></div><div>Implementation:</div><div>We need a way for applications to describe and own those subdirectories inside XDG user dirs. I think this could be as simple as the application dropping a desktop file on installation, in a well-known directory - for example $XDG_DATA_DIRS/xdg-user-dirs. Such a desktop file would have a structure like</div>
<div><br></div><div>[Directory]</div><div>Name=Webcam Snapshots</div><div>Name[it]=Scatti dalla Webcam</div><div>Name[es]=...</div><div>Name[fr]=...</div><div>Parent=$XDG_PICTURES_DIR</div><div>Icon=icon-name-from-theme (optional)</div>
<div><br></div><div>An utility like xdg-user-dirs-update would then take care of renaming such directories early at login, together with their parents. Toolkit support would be achieved with a function that returns the full path of a subdirectory given the basename of its desktop file descriptor.</div>
<div><br></div><div>In the example above, if the file is called "gnome-webcam.desktop", a GNOME application would call g_get_user_special_dir_for_id ("gnome-webcam.desktop"); which would return "$HOME/Pictures/Webcam Snapshots" in English and "$HOME/Immagini/Scatti dalla Webcam" in Italian.</div>
<div><br></div><div>[1] <a href="https://bugzilla.gnome.org/show_bug.cgi?id=712245">https://bugzilla.gnome.org/show_bug.cgi?id=712245</a></div><div><br></div><div>Feedback welcome!</div><div>Cosimo</div></div>