Unclutter Your Home Directory
Table of Contents
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
XDG_DATA_HOME=/home/somebody/.local/share
XDG_CONFIG_HOME=/home/somebody/.config
XDG_SEAT=seat0
XDG_SESSION_TYPE=tty
XDG_CACHE_HOME=/home/somebody/.cache
XDG_SESSION_CLASS=user
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
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'
(Source)
Gradle ∆
(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
.
gnupg ∆
Defaults to ~/.gnupg
.
export GNUPGHOME='/some/other/dir'
npm ∆
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.
Example:
~/.local/bin
is in PATH
. You can create an executable shell script therein named firefox
:
#!/bin/sh
/usr/bin/firefox --profile /path/to/profile "$@"