Organize the home folder

Hey!

How do you Guys organize your home folder? I’m trying to figure out how to make it so that When You install a new application it doesn’t Put stuff loose all over the home folder, but puts it in a contained subfolder (like “apps”) and have everything work fine. I just wasn’t sure how to put that into Google.

Any Ideas?

Unfortunately it is up to every program to decide where to put their config/data.
You can, however, configure most(?) tools to respect the XDG Spec.
See this boomer’s video for a great summary.

4 Likes

In most cases, the global config stuff will be placed in /usr/[share|local] sub directories. If you are installing from source, you can usually specify during the build process, where you want the files to be stored.

But ultimately, it all depends on if the developers gave you the ability to do this. Otherwise, you will have to go back behind the installer and symlink or move all of your stuff.

@oO.o weren’t you working on such a project?

If you use something like flatpak or snap you may be able to do it with those regardless of where the app thinks it puts the files. But with applications you install directly on your system I dont think there is a convinient way to do this either.

I use this and symlink some things into it that don’t support it by default. Doesn’t work for everything though. Tmux devs for instance refused to implement it.

2 Likes

Oh! hey look at that :smiley: They finally added it upstream this year, it seems??

well that was manual, but later dynamic $XDG_CONFIG_HOME was added
exciting!

## From a user with no existing sessions:
$ grep XDG_CONFIG_HOME /tmp/tmux/tmux
Binary file /tmp/tmux/tmux matches
$ mkdir -p /tmp/{yay/tmux/,homer}; touch /tmp/yay/{bash_completion,tmux/tmux.conf}; XDG_CONFIG_HOME=/tmp/yay HOME=/tmp\
/homer strace -f /tmp/tmux/tmux new-session -d -t mymux |& grep -E 'yay|homer|tmux\.conf'                                   
 ....
[pid 4081918] lstat("/etc/tmux.conf", 0x7ffd3d9a1650) = -1 ENOENT (No such file or directory)
[pid 4081918] lstat("/tmp/homer", {st_mode=S_IFDIR|0775, st_size=40, ...}) = 0
[pid 4081918] lstat("/tmp/homer/.tmux.conf", 0x7ffd3d9a1650) = -1 ENOENT (No such file or directory)
[pid 4081918] lstat("/tmp/yay", {st_mode=S_IFDIR|0775, st_size=80, ...}) = 0
[pid 4081918] lstat("/tmp/yay/tmux", {st_mode=S_IFDIR|0775, st_size=60, ...}) = 0
[pid 4081918] lstat("/tmp/yay/tmux/tmux.conf", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
[pid 4081918] lstat("/tmp/homer", {st_mode=S_IFDIR|0775, st_size=40, ...}) = 0
[pid 4081918] lstat("/tmp/homer/.config", 0x7ffd3d9a1650) = -1 ENOENT (No such file or directory)
[pid 4081918] openat(AT_FDCWD, "/tmp/yay/tmux/tmux.conf", O_RDONLY) = 8
[pid 4081919] stat("/tmp/homer/.terminfo", 0x557996e9ba00) = -1 ENOENT (No such file or directory)
[pid 4081919] faccessat(AT_FDCWD, "/tmp/yay/bash_completion", R_OK) = 0
[pid 4081919] openat(AT_FDCWD, "/tmp/yay/bash_completion", O_RDONLY) = 3
 ....
^C
$ /tmp/tmux/tmux kill-session -t mymux

Though depends a bit on your distro’s versions as to when that might be patched in. Using -f in aliases would be a pain when hoping users/systems etc (and setting global aliases is a can of worms/pain); though, usually the reasoning is for version control/backup/ocd (which all all valid reasons) and so symlink may be just as easy on older systems (but only half helps the ocd…). And in the case of version control with no roaming home directory, if you’re pulling down configs for one user then it’s not much more to pull an alias etc.

Either way, that upstream change is good news. It may be in archlinux now, I’ve not actually poked around my own system yet.


To follow this up regarding which applications may respect it,

a (certainly) non-comprehensive list in at archlinux wiki here in case anyone wants a quick way to check some that do.
(EDIT: hah, that’s in @foo 's linked video; I guess it’s typed here now for convenience)


If you can containerize whatever it is (may require some fiddling to actually setup and get working) then that can work as others have mentioned (to try and keep a particularly annoying application organized). Sadly if something doesn’t behave, often it’s not opensource or if it’s hard to get the maintainer to change things, its a question of deciding if it’s worth the effort of figuring out the application and beating it into the right places. (XDG/HOME, LD_LIBRARY_PATH, or if unlucky, symlinks, chroot/container/RPATH-updates/manual-hexeditor… * shudders *). I suppose it also depends a bit on if you have to update it regularly or not.

2 Likes

Based Lukeposter

FPBP

Oh cool, they finally caved. Looks like it’s in the current rc, so won’t be widespread for a while.