GNOME Goal: XDG Base Directory Specification Usage

Problem

Unix like systems have traditionally lacked a standard way to store application or user data on a per-user basis. Consequently these data are often stored in an ad-hoc, inconsistent, and problematic way in "dot files" of the user's home directory.

This is a problem because:

  • It breaks when sharing a home directory between different machines, or sessions (eg. using NFS)
  • Not cleanly separating cache, runtime (eg. sockets), or app data from user settings make it very difficult to manage
  • It makes it extremely challenging to perform smart or selective migration of settings between different OS versions
  • It is hard to reset settings without breaking things
  • It is hard to determine how to clear cache data to make room when the disk is filling up
  • It is hard to write a robust and efficient backup solution
  • It doesn't allow an admin flexibility to change where data and settings are stored
  • It dramatically increases the complexity and incoherence of the system for administrators
  • Aggregated across the entire OS it is an embarrassing mess

See one example user's story in this post.

Guidelines

FreeDesktop has issued a recommended solution for this problem.

  • Separation of user data, preferences, and cache items
  • Backwards compatibility should be taken into account
  • If you remove the .cache folder, the user MUST not notice it except maybe for performance (might be huge performance drop)

  • If you remove the .config folder, the user will see all the preferences reset to the default but without any data loss.
  • .local should be treated as any other user data
  • If you are storing application logs, you may want to consider using syslog or the systemd journal instead

Read this more detailled explanation of the XDG specification.

Bonus point: if the user chooses a default preference, this preference should not be saved anywhere and the corresponding entry in the config file should be empty (or "default" or whatever). This way, we are sure that an user does not keep the 10 years old default without even noticing it and that his default setup is correctly upgraded.

{i} Instructions on how to recognize a module affected by this goal.

The application is a target for this goal if:

  • the application stores file in an hidden folder others than the XDG ones
  • OR if removing the .cache or the .config folders induces data loss for the user
  • OR removing the .config folder doesn't get the application in its default configuration

Examples

GLib

const char *cache_dir = g_get_user_cache_dir ();
char *mydir = g_build_filename (cache_dir, "myapp", NULL);
/* use it */
g_free (mydir);

Python

import os
from gi.repository import GLib
mydir = os.path.join(GLib.get_user_config_dir(), 'myapp')

or

_runtime_dir = os.environ.get('XDG_RUNTIME_DIR', os.environ.get('XDG_CACHE_HOME', os.path.join(os.path.expanduser("~"), '.cache')))
_config_dir = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser("~"), '.config'))
_cache_dir = os.environ.get('XDG_CACHE_HOME', os.path.join(os.path.expanduser("~"), '.cache'))
_data_dir = os.environ.get('XDG_DATA_HOME', os.path.join(os.path.expanduser("~"), '.local/share'))

Vala

Environment.get_user_cache_dir()

Migration

A good example are the empathy patches by fpeters:

GLib convenience functions: here

Status of this goal

{i} Tip: If you choose to work on a module, create the bug report on the GNOME bugzilla. This way people will know someone already works on it, and won't duplicate the work you're doing.
/!\ Please make the bug report depend on the tracker bug for this goal.

State

Markup

todo

<: #ff8080> todo

patch

<: #ffc849> [[GnomeBug:xxxxx|patch]]

done

<: #80ff80> [[GnomeBug:xxxxx|done]]

not needed

<: #80ff80> not needed

Above are the states and corresponding markup to update the modules state table below.

Tarball

Status

core

epiphany

done

evolution-data-server

done

gdm

done

gnome-control-center

not needed

gnome-desktop

done

gnome-menus

not needed

gnome-settings-daemon

done

gnome-shell

done

gstreamer

done

gvfs

done

mutter

done

nautilus

done

telepathy-mission-control

done

core-utilities

brasero

done

empathy

done

eog

done

evince

done

file-roller

done

gcalctool

not needed

gnome-dictionary

done

gnome-font-viewer

done

gnome-icon-theme

not needed

gnome-keyring

done and done

totem

done

yelp

done

core-extra

gnome-backgrounds

not needed

core-fallback

gconf

done

gnome-panel

done done

metacity

done

core-os-services

dbus

patch

NetworkManager

not needed

PackageKit

done

pulseaudio

done

core-deps

gnome-doc-utils

not needed

gtk+

done

fontconfig

done

libgnomekbd

674874 674873 - done

libgtop

not needed

libgweather

not needed

libICE

to do

librsvg

not needed

libsoup

not needed

libwnck

not needed

mousetweaks

done

pango

done

poppler

done

totem-pl-parser

not needed

zenity

not needed

apps

accerciser

done

anjuta

done

cheese

done

devhelp

not needed

evolution

done

gedit

done

glade

done

gnome-games

done

gnome-devel-docs

not needed

gnome-nettool

not needed

grilo

done

orca

done

seahorse

not needed

totem

done

vinagre

done

Other

abiword

done

abrt

done

alacarte

done

aMule

to do

Anthy

to do

aptitude

Expected a color value "#" after "#"

done

Ardour

done

arduino

bug needed

Audacity

to do

bash

WONT DO

banshee

done

Blender

done done

baobab

done

bzr

done

cabal

to do

patch wanted

clamz

to do

Chrome

done

conky

to do

compiz

to do

CUPS

WON'T FIX

d-feet

done

Darktable

to do

deskbar-applet

done

Desura

to do

Dropbox

to do

EasyTAG

done

Eclipse

to do

Help wanted

Elluminate

to do

emacs

to do

fedora-packager-setup

WON'T FIX

Festival

to do

Filezilla

done

FontForge

to do

freecol

done

firefox

to do

patch wanted

flash plugin

WON'T FIX

galculator

done

gimp

done, done

git

done

gitk

done

git-bz

done

gksu

to do

gnome-exe-thumbnailer

to do

gnome-tweak-tool

done

gnote

done

gnumeric

to do

gnupg

WON'T FIX

Google Earth

to do

gthumb

done

guvcview

to do

hamster-applet

done

hardinfo

to do

Hugin

to do

jackd

to do

jhbuild

done

kdenlive

to do

less

patch sent via email

lftp

to do

libdvdcss

to do, to do

libreOffice

done

libreport

done

libvirt

done

lightdm

to do

imsettings

done

m17n-lib

to do

matplotlib

to do

minecraft

to do

mono

done

mplayer

to do

mtpaint

to do

MyPaint

done

nss

to do

npm

to do

patch wanted

Octave

to do

patch wanted

onboard

to do

OpenShot

to do

Opera

to do

pidgin

to do

patch wanted

planner

done

reinteract

to do

remmina

to do

rhythmbox

done

rpm

to do

SANE

to do

Scribus

to do

SCUMMVM

to do

setroubleshoot

to do

Shotwell

done

Shutter

to do

Skype

to do

speech-dispatcher

done

spice

done

ssh

WON'T FIX

stardict

to do

Steam

to do

stellarium

to do

subversion

to do

synaptic

to do

systemtap

to do

Thunderbird

to do

Titanium

to do

Transmission

done

tomboy

done

Twinkle

to do

ufraw

done

Vidyo

to do

vim

to do

virt-manager

done, done

VirtualBox

to do

VNC

to do

Wine

WON'T FIX

wxWidgets

to do

patch wanted

XChat

patch

xchat-gnome

patch

Xine

to do

xsane

to do

xscreensaver

WON'T FIX

See Also

Initiatives/GnomeGoals/XDGConfigFolders (last edited 2016-07-07 22:40:52 by AlexandreFranke)