Standards: Defending $HOME
The XDG base directory specification
defines the locations where applications should store application-private files on Linux, instead of dumping them into
$HOME. In short:
- cache files go into
$XDG_CACHE_HOMEis not defined or empty)
- settings go into
$XDG_CONFIG_HOMEis not defined or empty)
- application data goes into
$XDG_DATA_HOMEis not defined or empty)
- runtime data goes into
While most applications and libraries have implemented the standard over the last 10 years, some applications (often due to a lack of awareness) fail to follow it.
Here are a few practical steps for Linux users that are fed up with the latter applications littering in their home directory:
Step 1: Adjust some environment variables
As the process of logging into an account tries to create some files in
we need to adjust some settings to instruct these applications to place them at more suitable locations.
Add the following line to
Add the following lines to
/etc/lightdm/lightdm.conf (if you use LightDM)
or try adding
.pam_environment (this might or might not work depending on the display manager).
Step 2: Check whether applications support the XDG base directory spec
Check whether existing dot-files and dot-directories can be moved – many applications already support the XDG base directory specification, but do not move existing files:
- Rename the dot-files and/or dot-directories of an application, run the application and check whether the
application created entries in
- If this is the case, migrate the existing dot-files to those directories.
Step 3: File bug reports
Check whether bug reports exist for the remaining applications, or file new bug reports:
- The Arch wiki entry on XDG Base Directory support is an invaluable resource.
- The XDG Migration Status page provides an overview of applications I intend to tackle myself.
Step 4: Make
$HOME read-only (yes, really)
chmod -222 $HOME
to prevent the creation of new dot-files and dot-directories in your home directory.
From this point on, the number of dot-files and dot-directories can only shrink as the remaining applications get fixed and start conforming to the XDG base directory spec, while no new dot-files and dot-directories can be added to your home directory.