Move mackup's config to $XDG_CONFIG_HOME/mackup

- move all of mackup's config files into $XDG_CONFIG_HOME/mackup:
  + ~/.mackup.cfg => configs for mackup itself
  + ~/.mackup/*.cfg => custom sync rules applied by mackup
- add automatic installation of `pipx` and `mackup` during the
  setup of the dotfiles
  + `pipx`'s config is moved into $XDG_CONFIG_HOME
  + `mackup`s config locations are adapted via a "little hack"
This commit is contained in:
Alexander Hess 2023-04-11 00:33:39 +02:00
commit 1cccb7df0e
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
10 changed files with 68 additions and 6 deletions

View file

@ -2,6 +2,7 @@
# such that they are available within a user's $HOME as common "dotfiles"
export XDG_BIN_HOME="$HOME/.local/bin" # temporarily set here; mainly set in ~/.profile
export XDG_DATA_HOME="$HOME/.local/share" # temporarily set here; mainly set in ~/.profile
@ -24,6 +25,27 @@ git --git-dir=$XDG_DATA_HOME/dotfiles/ --work-tree=$HOME config --local status.s
[ -d "$XDG_DATA_HOME/gnupg" ] && chmod 700 $XDG_DATA_HOME/gnupg
if _command_exists pip; then
# Ensure `pipx` is installed in the user's local environment
pip install --upgrade --user pipx
# (Re-)Install `mackup` via `pipx` in the user's local environment
export PIPX_BIN_DIR=$XDG_BIN_HOME
export PIPX_HOME="$XDG_DATA_HOME/pipx"
$XDG_BIN_HOME/pipx uninstall mackup
$XDG_BIN_HOME/pipx install mackup
# Litte Hack: Make `mackup` respect the XDG directory structure
sed -in 's/VERSION = \".*\"/VERSION = \"0.999.0\"/g' $HOME/.local/**/mackup/constants.py
sed -in 's/CUSTOM_APPS_DIR = \"\.mackup\"/CUSTOM_APPS_DIR = \"\.config\/mackup\"/g' $HOME/.local/**/mackup/constants.py
sed -in 's/MACKUP_CONFIG_FILE = \"\.mackup\.cfg\"/MACKUP_CONFIG_FILE = \"\.config\/mackup\/mackup\.cfg\"/g' $HOME/.local/**/mackup/constants.py
$XDG_BIN_HOME/mackup restore
fi
if _command_exists zsh; then
# Set the $ZDOTDIR in /etc[/zsh]/zshenv if that is not already done
@ -60,6 +82,17 @@ fi
echo 'Defaults !admin_flag' | sudo tee /etc/sudoers.d/disable_admin_note
# Warn user if ~/.local/pipx already exists
# => As we use the custom $XDG_DATA_HOME/pipx location,
# the user should NOT `pipx`'s default install location as well
if [ -d "$HOME/.local/pipx" ]; then
echo
echo "~/.local/pipx already existed!"
echo "It is recommended to delete this location in favor of $XDG_DATA_HOME/pipx"
echo
fi
echo
echo "Probably it's a good idea to restart the shell"
echo "Make sure to start bash or zsh as a login shell the next time"