Clean Home

May 17, 2021 — Reyan Chaudhry


If you are genuinely insane like me, you may find that having “clean” directory names/structures and no dotfiles in your home directory gives you a sense of power, makes you feel as if you have something to be proud of. If so, here is a guide on achieving this relatively maniacal goal with minimal (ok that’s a lie) difficulty.

bruh
I do indeed get no real work done.

On a side note, the reason I’m putting actual effort into this is that vizs seems to have (sensibly, mind you) given up on maintaining his declutter-home repo, which was basically the bible for us clean home enthusiasts.

Fear not, however! As I plan on providing a sane, expanded, and updated replacement to said README in this article.

The Easy Stuff

Lets get some of the more obedient software out of the way first, shall we? Your shell is probably what triggers you most when it comes to dotfiles, and bash is infamous for littering your home directory with trash. Unfortunately, however, nothing can be done to save our fellow bash users, switch to zsh/mksh or bust lmfao.

For us intellectuals, setting the env var ZDOTDIR in /etc/zsh/zshenv and then putting all our necessary zsh files in the specified directory should be satisfactory. Note, however, that you can choose a custom ZSHRC file as well, should you desire that.

What’s next is probably the most crucial step here, setting XDG env vars. Here are the 3 you really need to know:

Most programs should begin to adhere to these new standards after a couple restarts, a good practice is to simply dump everything you have in ~/.config or such straight into your newly desired directory and keep track of which programs break. Remember those as we will need them later.

Here’s where we get to spamming env vars for programs that don’t normally obey XDG, specifications, some important ones being:

Program Env Var
dialog DIALOGRC
GIMP GIMP2_DIRECTORY
gnupg GNUPGHOME
readline INPUTRC
less LESSHISTFILE
mail MAIL / MAILRC
go GOBIN / GOPATH
pass PASSWORD_STORE_DIR
pulseaudio [1] PULSE_COOKIE
python [2] PYTHONUSERBASE
shell-history HISTFILE
cargo CARGO_HOME
rustup RUSTUP_HOME
weechat WEECHAT_HOME

As an aside, you can set custom PATH’s to house your scripts and such wherever you’d like, ridding the need for .local entirely

Xorg

Another massive pain in the home dir’s ass is X and all the bullshit that it likes to dump there. The problem is magnified once you realize how annoying Xorg is when it comes to fixing it using it’s built in settings. What’s normally used to start X display servers is the startx script, which is old, inefficient, and bloated. It’s recommended to instead use sx and modify that to your needs instead (lines 25, 26 and 29). sx will start an Xorg instance as normal and save you many headaches.

ssh

More info soon.

npm

npm is a bit less straightforward than it’s equally soy yet slightly more bearable python cousin, there a couple extra steps involved. First and foremost, set the npm_config_userconfig env var to a specific file. This file will be the per-user npm configuration file. Next, run

npm config edit

To open up your config. Go to the line with the cache option and set it to whatever directory you’d like. What you choose will be used instead of the normal ~/.npm. It will still dump the package-lock shit in your home whenever you decide to install something, but at least those can be removed manually without any worries. Worth the slight inconvenience IMO.

Flags

Now that we’re done with environment related stuff, let’s get to the fun part, manually defining flags! Quite a few programs have these, with the following being some of the more relevant ones:

Program Flag
dunst -conf
picom --config
sxhkd -c
wget --no-hsts / --hists-file

As you can see, most programs use some variation of c/config/conf to point at a specific config file. Laying out all possible programs and variations here would be pointless, as the list varies from user to user. Just check the man page of the desired program and search for ‘directory’ or ‘config’ and the like, you’ll find what you are looking for eventually.

Patching

Of course, most smaller programs (or those which you don’t expect to be updated anytime soon) can be manually patched to adhere to yours’ (or XDG’s) specified directory requirements. Ample use of grep, sed, and Vim substitution can make this task trivial, just be careful not to mess things up. And obviously, submitting PR’s to make things easier for others in the future would never hurt.

Homedir Roomba

You can use a roomba script to automatically remove certain pesky directories (such as Thunar’s constant caching of image thumbnails) every 60 seconds or such. This removes the need to constantly check for and manually delete said directories.

Conclusion

I’ve reasonably left out too many specifics in this post, as the vast variety of software on Linux makes it hard to account for everything, but I hope you’ve gotten the gist of how to manage a clean home on your own. It’s not too difficult and genuinely allows you to have a better overlook of your system and to manage it more effectively. All opinions expressed here, are, of course, subjective and my own.

Big thanks to vizs, gk, and others who worked on this before me and inspired me to write this.

Have a good day.