Extending xdg-user-dirs

Cosimo Cecchi cosimo.cecchi at gmail.com
Mon Mar 3 16:42:11 PST 2014


Hi all,

I went ahead and wrote an implementation of my proposal, which you can now
find here
- https://github.com/cosimoc/xdg-user-dirs/tree/wip/user-directories
- https://github.com/cosimoc/xdg-user-dirs-gtk/tree/wip/user-directories(updates
to the GTK version of the tool)
- https://github.com/cosimoc/glib/tree/wip/user-directories (adds new GLib
API)

One caveat is in order to make this possible, I essentially rewrote
xdg-user-dirs to use GLib APIs - I didn't want to parse keyfiles manually.
So you'll need GLib to build the tool... I don't think that'll be a big
deal, since GLib is a build dependency for a lot of things these days.

Comments welcome!
Cosimo


On Wed, Jan 15, 2014 at 11:00 AM, Cosimo Cecchi <cosimo.cecchi at gmail.com>wrote:

> Hi all,
>
> 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.
>
> Use cases:
> * 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.
>
> * 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.
>
> There's a bunch of similar cases, which you can find in this bug [1] where
> this message originates from.
>
> Implementation:
> 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
>
> [Directory]
> Name=Webcam Snapshots
> Name[it]=Scatti dalla Webcam
> Name[es]=...
> Name[fr]=...
> Parent=$XDG_PICTURES_DIR
> Icon=icon-name-from-theme (optional)
>
> 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.
>
> 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.
>
> [1] https://bugzilla.gnome.org/show_bug.cgi?id=712245
>
> Feedback welcome!
> Cosimo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xdg/attachments/20140303/8c11e5d6/attachment.html>


More information about the xdg mailing list