matyama / configs

Configuration and scripts for Ubuntu desktop
MIT License
2 stars 0 forks source link

Unclutter HOME by conforming to XDG specification #17

Open matyama opened 2 years ago

matyama commented 2 years ago

Unclutter $HOME directory by moving config files to XDG_CONFIG_HOME, XDG_DATA_HOME and/or XDG_CACHE_HOME.

See Arch's docs on XDG support.

This is a tracking issue for following apps/tools:

matyama commented 2 years ago

helm >= 3 supports XDG out of the box so it should be safe to drop/migrate ~/.helm (check helm version first tho)

matyama commented 2 years ago

NSS data in ~/.pki should be safe to move to XDG directories, see: https://bugzilla.mozilla.org/show_bug.cgi?id=818686 . Also Chrome does seem to use XDG (after quick check of the contents of XDG_CONFIG_HOME).

Migration commands:

mkdir -p $XDG_CONFIG_HOME/pki/nssdb $XDG_DATA_HOME/pki/nssdb && \
  mv $HOME/.pki/nssdb/pkcs11.txt $XDG_CONFIG_HOME/pki/nssdb && \
  mv $HOME/.pki/nssdb/*.db $XDG_DATA_HOME/pki/nssdb && \
  rm -r $HOME/.pki 
matyama commented 2 years ago

NSS data in ~/.pki should be safe to move to XDG directories, see: https://bugzilla.mozilla.org/show_bug.cgi?id=818686. Also Chrome does seem to use XDG (after quick check of the contents of XDG_CONFIG_HOME).

After further testing Chrome does seem to re-create ~/.pki and indeed they have an open issue for it: https://bugs.chromium.org/p/chromium/issues/detail?id=1038587.

Adding an item for it to the list.

matyama commented 2 years ago

~/.pki is also created by vscode - mentioned in https://bugzilla.mozilla.org/show_bug.cgi?id=818686 and verified

Adding an item for it to the list.

matyama commented 2 years ago

~/.vscode is problematic too (XDG support is still an open issue). It's contents is

.vscode
├── argv.json
└── extensions

At least partial fix could be

export VSCODE_EXTENSIONS="$XDG_DATA_HOME/vscode/extensions"

or setting a global alias or a script for running code with --user-data-dir ~/.config/vscode --extensions-dir ~/.config/vscode/extensions options.

The argv.json file still remains an issue tho.

matyama commented 2 years ago

base16-shell has

Best approach would be to open a PR. Alternatively, for now and to test, profile_helper.sh could be modified/replaced in Makefile (as the last step of base16-shell target).

Note: Probably best place to use for these would be either XDG_STATE_HOME or XDG_CONFIG_HOME.

matyama commented 2 years ago

ipython >= 8.x supports XDG

It's not quite clear which XDG directories one should use (except obvious XDG_CONFIG_HOME). https://wiki.archlinux.org/title/XDG_Base_Directory mentions that despite the fact $HOME is still the default dotfile path, if XDG directories shoudl be supported and the docs/PRs/issues mention that XDG_CACHE_HOME might be used by cython.

So it should be sufficient to just run

mv ~/.ipython $XDG_CONFIG_HOME/ipython
matyama commented 2 years ago

GHC should support XDG since 9.2.1 according to this commit.

This means that older versions probably will keep using/creating ~/.ghc, unless changes to ghcup will cover this case as well.

As a potential workaround (perhaps just for older GHC versions), one could set a global ghci alias that will force storing history file locally:

alias ghci="ghci -flocal-ghci-history"

Although, this might pollute the $PWD at unexpected locations, such as $HOME - which would defeat the purpose.

matyama commented 2 years ago

GHC should support XDG since 9.2.1 according to this commit.

This means that older versions probably will keep using/creating ~/.ghc, unless changes to ghcup will cover this case as well. .... Although, this might pollute the $PWD at unexpected locations, such as $HOME - which would defeat the purpose.

Even with ghcup changes (see a7b800aeb9027e310bb79d4c14c4ad6eced27089), ~/.ghc is still created with older compilers.

matyama commented 2 years ago

yarn is partially supported and according to the XDG list. The issue is still open as there are two remaining problems with current implementation:

Other than that ~/.yarn should go to XDG_DATA_HOME and other yarn dirs similarly to XDG_CACHE_HOME etc.

matyama commented 2 years ago

~/.redhat dir is most likely due to vscode's user data collection. Since vscode does not currently support XDG by itself, it's quite unlikely that the telemetry would be configurable.

Therefore, the best option to get rid of ~/.redhat is to disable the telemetry in vscode and just remove the directory.

matyama commented 2 years ago

Since the shell in use is zsh, bash configs are not commited in this repo. So to change the location of the ~/.bash_history file once can manually run the following:

mkdir -p "$XDG_STATE_HOME"/bash
mv ~/.bash_history $XDG_STATE_HOME/bash/history

and add this line to ~/.bashrc:

export HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/bash/history"
matyama commented 2 years ago

~/.selected_editor is generated/used by select-editor and should not be necessary when EDITOR and VISUAL environment variables are set. For reference see: https://askubuntu.com/questions/55022/changing-default-crontab-editor

Tested by removing the file and running crontab -e and it seems fine - the file was not re-created and it opened in $EDITOR.

matyama commented 2 years ago

Scala 3 (dotty), does not recognize scala -Dscala.shell.histfile=... and creates ~/.dotty_history when running a REPL.

After some googling, I've not found any relevant resources on this issue - i.e. how to change the default location where the REPL history is stored.

matyama commented 2 years ago

nvidia-settings does not support XDG specs at this moment. Current workaround is to call it with --config option to set a custom config file path (under XDG_CONFIG_DIR).

c7edcf0035611caa460026f53c69329b504db299 introduces an alias for nvidia-settings which works when called manually from a terminal but ~/.nvidia-settings-rc still gets (re)created when the program is invoked as a Gnome app (i.e. from the menu).

A possible hack to solve the remaining issue could be to modify /usr/share/applications/nvidia-settings.desktop by adding the same --config option to the command underExec. This would also need a sudo update-desktop-database.

matyama commented 2 years ago

1e95ce3 fixes remaining issue with the Gnome desktop nvidia-settings application config path. There is a

make nvidia-settings-rc-xdg-path

command to edit the desktop entry accordingly.

matyama commented 8 months ago

4f7f79bbff04ba5f0fdc6760d4ee8017ba35cf71 removes the auxiliary ~/.zshenv in favor of a (systemd) user-specific config under $XDG_CONFIG_HOME/environment.d/.

matyama commented 8 months ago

1f2a9a8168e5401f19d59f9f9ec352b0704a9674 is an attempt to get rid of ~/.rpmdb created on Ubuntu (probably by apt or snap or something).

Note that it still might get created, because the overshadowing rpm alias will only work (be set) in ZSH context.

matyama commented 8 months ago

987255151f3ec0182e9c08ece590213d998f11d1 moves (and solves the issue of) the ~/.binenv.

matyama commented 8 months ago

b3c819b splits and moves ~/.kube to $XDG_CONFIG_HOME/kube and $XDG_CACHE_HOME/kube

matyama commented 8 months ago

8d2bd51 is an attempt to get rid of ~/.debug

Note that the perf config is currently set just for --system, so it's a question, whether if invoked under current USER it's gonna work. The issue with using --user option is that it creates ~/.perfconfig, which defeats the purpose here.

matyama commented 8 months ago

fe59105 removes thunderbird which solves the issue with ~/.thunderbird

matyama commented 2 months ago

created/used by keybase app:

matyama commented 2 months ago

bash config scripts such as ~/.bashrc were addressed in 752686b