Unclutter Your Home Directory

It's still a problem for many people: applications create directories and files directly under $HOME, not even using the freedesktop XDG standard for user directories.

Manual cleanup is often required after removing software, but more importantly: how can we get these directories out of the way even for software that's in use?

Nota bene: my filemanager is always set to show "hidden" files. If yours isn't, try Ctrl-H, you might be surprised what you find.

XDG User Directories

These should be set first of all. Check with

$> env | grep XDG

If you aren't using a pre-configured desktop environment you might need to set those under your HOME manually by exporting them in your shell's profile files (e.g. ~/.bash_profile) or something like ~/.xinitrc:

# also see system directories in /etc/profile
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"

This might already solve a lot of problems.


Java applications

There's a very simple trick to get all Java stuff out of the way via the user.home option, which can be set permanently through the _JAVA_OPTIONS variable.

export _JAVA_OPTIONS='-Duser.home=/some/other/dir'

Further options can be added, space-separated. Example, including anti-aliasing for fonts and GTK look:

export _JAVA_OPTIONS='-Duser.home=/some/other/dir -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true  -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel swing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'



(Build system for the JVM) - defaults to ~/.gradle.

export GRADLE_USER_HOME="/some/other/dir"
# or
export GRADLE_OPTS="$GRADLE_OPTS -Dgradle.user.home=/som/other/dir"

Possibly the last option could also be added to _JAVA_OPTIONS.


Defaults to ~/.gnupg.

export GNUPGHOME='/some/other/dir'


export NPM_CONFIG_USERCONFIG='/some/other/dir/npm/rc'

This file (not a directory) should then also contain

cache = /some/other/dir/npm

which otherwise defaults to ~/.npm

The sad rest

Unfortunately there are still a lot of applications that cannot be configured in this way, or it's too much work to configure each and every one.

Most notably, possibly, Firefox.

Game managers like Lutris provide solutions for games.

One can also start an app with a different HOME directory, e.g.

$> HOME="$XDG_CONFIG_HOME/nameofgame" nameofgame

(this can have undesired side-effects) or write a wrapper script with specific command-line options as a drop-in replacement for the executable.


~/.local/bin is in PATH. You can create an executable shell script therein named firefox:

/usr/bin/firefox --profile /path/to/profile "$@"