localdir icon indicating copy to clipboard operation
localdir copied to clipboard

Get rid of remaining dotfile clutter in ~/

Open ayekat opened this issue 9 years ago • 23 comments

This is the "hard resistance" of hidden files that still remain in my home directory, and for which there is no trivial solution listed in this Arch Wiki article:

  • [x] .adobe: Created by flashplugin [FIXED] Flash is dead, see [comments below][c:mozilla]
  • [x] .android: Created by adb (Android Debug Bridge) [FIXED] See comments below
  • [ ] .anthy: Created by anthy (Japanese IM) (bug report) [UNLIKELY] Project appears dead
  • [x] .asoundrc.disabled: Ugly hack for changing ALSA soundcard [FIXED] See comments below
  • [x] .ivy2: Created by sbt (Scala Build Tool) [FIXED] See 3e7375f
  • [x] .macromedia: Created by flashplugin [FIXED] Flash is dead, see [comments below][c:mozilla]
  • [x] .mailcap: Created/used by claws-mail and mutt [FIXED] for mutt (5a22d78) but [???] for Claws-Mail
  • [x] .mozilla: Created by firefox (and thunderbird) (bug report) [WORKAROUND] See 9c2138b2
  • [ ] .pki: Created by Chromium using libnss (issue), and thus WebEngine
  • [x] .rnd: Created by OpenSSL [FIXED] See b604d5038
  • [x] .sbt: Created by sbt (Scala Build Tool) [FIXED ~~except for ~/.sbt/preloaded~~ [FIXED]] See 3e7375f
  • [x] .sqlite_history: Created by sqlite, ~~cannot be configured (discussion) [UNLIKELY] Devs refuse to fix it (but may be open for patches)~~ [FIXED] (upstream)
  • [ ] .ssr: Created by simplescreenrecorder (Qt4) [???]
  • [x] .uim.d: Created by UIM [FIXED] Switched to iBus
  • [x] .w3m: Created by w3m [FIXED] See 896234f

Some of them are not essential and can be occasionally purged with dotbloat, but some others (.anthy, .mailcap, .pki and .ssh) are permanently required, and thus more annoying.

Explicitly not listed

The following 3 directories are not listed because either applying the XDG base directory specification to them does not make any sense, or because we need to put application data at least somewhere:

  • .local: Contains all the application files, neatly organised and inspired by the Linux FHS
  • .pam_environment: Bootstrap ("chicken-or-egg") issue, as it is the very first thing that sets environment variables, at login (some people are trying it nevertheless: [1])
  • .ssh: Bootstrap ("chicken-or-egg") issue, because it is the very first thing that is checked for SSH logins (i.e. before a login even happens) (some people are trying it nevertheless: [2])

ayekat avatar Jan 08 '17 04:01 ayekat

For the ones where it is hardcoded, using a ~~wrapper script with an LD_PRELOAD for file system accesses~~ a FUSE filesystem might be a way...—need to investigate on that.

ayekat avatar Jan 19 '17 22:01 ayekat

OK, there is no real one-size-fits-it-all solution:

  • FUSE—even if it stores files and directories in the right locations—would make them appear in the home directory, nevertheless, which kind of defeats the initial purpose of keeping the home directory clean.
  • LD_PRELOAD is software-specific, and we might as well just fix the upstream code. Of course, if upstream refuses patches, we'll need to use LD_PRELOAD either way.

Besides, .rnd has been relocated with the RANDFILE variable. Let's see if OpenSSL puts it in the right location—marking as fixed for the moment.

For quite a few on that list, I will not search for a solution, but simply stop using them (e.g. .mozilla, .adobe, .macromedia, .mono) (e.g. I've made quite a successful transition from dwb to qutebrowser two weeks ago).

ayekat avatar Feb 09 '17 11:02 ayekat

For .asoundrc, it appears to be possible to use environment variables for setting the default sound card. This might be handy for temporarily setting a sound card when watching a film while hooked up to the 5.1 sound card (rather than keeping around a "disabled" configuration file that clutters our home directory).

--edit-- It works—in my particular case, it's simply

$ ALSA_CARD=Device mpv path/to/some/video.mkv

and it uses my external 5.1 sound card.

ayekat avatar Apr 11 '17 11:04 ayekat

Commit 0524cadfb moves ~/.mozilla into $XDG_DATA_HOME by setting a different $HOME.

It's an ugly hack, but it works for me™, so I'm ticking it off as solved either way.

Also, after uninstalling flashplugin, .adobe and .macromedia no longer seem to be created, so I'm marking it as "solved". I assume that they would also appear in $XDG_DATA_HOME/mozilla.

ayekat avatar May 05 '17 08:05 ayekat

Concerning ~/.pki, I just stumbed over https://bugzilla.mozilla.org/show_bug.cgi?id=818686.

If this gets implemented by Mozilla, there is a chance that Chrome/Chromium (and thus qutebrowser) will follow.

This would also be a bit of "milestone" in that all dotfiles/dotfolders we care about would be finally gone (with the exception of ~/.anthy, which is unlikely to ever disappear, because the project is dead). The rest can be periodically nuked by dotbloat.

ayekat avatar Feb 19 '19 11:02 ayekat

It is possible to change the location of ~/.android, you just have to export the ANDROID_SDK_ROOT, ANDROID_EMULATOR_HOME and ANDROID_SDK_HOME variables, setting them to where you want your adb data directory to be. I set up mine to be in ~/.local/share/android

goll72 avatar Sep 15 '20 18:09 goll72

Hi, thanks for the input! I haven't tested it (it's been a while since I played around with Android for the last time), but I trust you it works :-)

ayekat avatar Sep 15 '20 19:09 ayekat

I noticed that some programs will use the adb daemon without using the environment variables that are setup (one example is DroidCam OBS). So it doesn't solve anything (for the ones using those programs).

goll72 avatar Oct 01 '20 10:10 goll72

Now simplescreenrecorder reads XDG_CONFIG_HOME. More details on its commit, it will be part of the next release.

tomodoro avatar Nov 28 '20 22:11 tomodoro

Ah, good to know, thanks. :slightly_smiling_face:

It's a bit unfortunate that $XDG_CONFIG_HOME/simplescreenrecorder must exist beforehand, but I guess this is already better than nothing.

ayekat avatar Nov 29 '20 14:11 ayekat

It is possible to change the location of ~/.android, you just have to export the ANDROID_SDK_ROOT, ANDROID_EMULATOR_HOME and ANDROID_SDK_HOME variables, setting them to where you want your adb data directory to be. I set up mine to be in ~/.local/share/android

That won't work. At least not for adb, see:

https://cs.android.com/android/platform/superproject/+/affbb260bf7d410faa89a789c29f786dbc170df6:packages/modules/adb/adb_utils.cpp;l=312

The path is hardcoded to "$HOME/.android", unfortunately.

guihkx avatar Jan 12 '21 23:01 guihkx

Regarding the .pki directory, Firefox doesn't use it anymore (unless it already exists):

https://hg.mozilla.org/projects/nss/rev/da45424cb9a0b4d8e45e5040e2e3b574d994e254

Chromium-based browsers and apps, however, still do:

https://bugs.chromium.org/p/chromium/issues/detail?id=1038587

guihkx avatar Jan 12 '21 23:01 guihkx

.android is partially fixed. Hardcoded paths remained in adb and some other tools: https://issuetracker.google.com/issues/160478861

pravorskyi avatar Nov 04 '21 23:11 pravorskyi

One issue I encountered is that ~/.ansible/tmp was still being cluttered even with Ansible wrappers in place.

The two available tmp configurations for ansible.cfg can help to remedy the problem. Note that remote_tmp probably only needs to be set to $XDG_CACHE_HOME when you run Ansible against localhost, i.e. your own machine like it's the case for me:

# https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-local-tmp
local_tmp           = $XDG_CACHE_HOME/ansible/.ansible/tmp

# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/sh_shell.html
remote_tmp          = $XDG_CACHE_HOME/ansible/.ansible/tmp

karras avatar Dec 20 '21 21:12 karras

Hey, thanks for the input!

~~Depressing~~Interesting that setting $HOME still doesn't catch all cases… I haven't run Ansible as a controller in this setup in a while now, so I'd need to check again. Do you set this in each project's ansible.cfg, or how do you solve that (AFAICT config merging isn't part of Ansible yet, so I'm not sure I could use my personal ansible.cfg somewhere else)?

For remote_tmp… I would probably need to know how the remote user likes to organise their home directory. For that, I'd have to go through a significant portion of the remote login procedure to get to a point where I can determine the values of the XDG basedir variables. Without any support from Ansible itself, I'm not quite sure this is doable in an elegant way.

I could also simply assume that the remote user also has the same localdir/dotfiles setup, but I'd like to avoid that (but to be honest, if I were to manage my own systems with Ansible, I'd probably use a dedicated ansible user—I typically don't care about the "cleanliness" of service account home directories :sweat_smile:). But it's nice to know that one could in theory override this. Thanks!

ayekat avatar Dec 22 '21 09:12 ayekat

I'd specify it only for specific projects, i.e. on a project level because as you said you'd encounter the XDG .local spec mostly only on ones own workstation.

karras avatar Dec 23 '21 07:12 karras

There's also .netrc which can be changed at least on the side of curl to CURLOPT_NETRC_FILE. Other programs might have similar options.

Thaodan avatar Nov 26 '22 11:11 Thaodan

.w3m: Created by w3m (appears hardcoded) [???]

https://github.com/tats/w3m/issues/130

Thaodan avatar Nov 27 '22 23:11 Thaodan

Changing $GPGHOME has the side effect of changing the path to the socket.

Thaodan avatar Nov 27 '22 23:11 Thaodan

.w3m: Created by w3m (appears hardcoded) [???]

tats/w3m#130

Thanks a lot! Adopted in 896234ff65db83d381d0c268aa93e6e567973bd3.

ayekat avatar Sep 02 '23 12:09 ayekat

Removed ~/.mono (Keepass) and ~/.thumbnails (Thunar), as I haven't used either of those applications for several years now.

Also marked ~/.mozilla as "worked around" (with the wrapper script). Realistically, it's not going to be implemented anytime soon, so I might as well make myself comfortable with the wrapper script. As it's not my main browser, that's "good enough" for me.

ayekat avatar Sep 04 '23 22:09 ayekat

Wasn't thumbnails the legacy location for apps using the xdg thumbnails? Anyone who tries Thunar again later should not need it.

Thaodan avatar Sep 04 '23 22:09 Thaodan