install.fairie/home/dot_local/bin/mackup/executable_mackup.tmpl
2023-08-08 01:29:21 -04:00

39 lines
1.9 KiB
Cheetah

{{- if ne .host.distro.family "windows" -}}
#!/usr/bin/env bash
# @file ~/.local/bin/mackup
# @brief Creates a wrapper around `mackup` to add support for XDG directories
# @description
# This script is a wrapper around the `mackup`. `Mackup` does not support XDG specification
# for its configuration. The script symlinks the `.config/mackup/.mackup/` folder to `~/.mackup` and
# the `.config/mackup/.mackup.cfg` file to `~/.mackup.cfg` before executing `mackup`. The symlinks
# are deleted after mackup runs.
#
# [mackup](https://github.com/lra/mackup) is a tool that can help in keeping your application settings
# in sync across multiple computers. It supports many different storage solutions like Dropbox, Google Drive, etc.
# to store the settings and sync them across machines. It can also help in restoring settings on a new installation.
# A number of applications are supported out of the box. It is trivial to add more applications. Refer to the
# [documentation](https://github.com/lra/mackup/blob/master/doc) for details.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Create symlinks pointing to stored configurations
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup/" ~/.mackup
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup.cfg" ~/.mackup.cfg
### Run original mackup executable
if command -v brew > /dev/null && brew list | grep mackup > /dev/null; then
$(brew --prefix)/bin/mackup $* || echo ''
elif (command -v pip3 > /dev/null && pip3 list | grep mackup > /dev/null) || \
(command -v pip > dev/null && pip3 list | grep mackup > /dev/null) || \
(command -v pipx > dev/null && pipx list | grep mackup > /dev/null); then
~/.local/bin/mackup $* || echo ''
else
logg warn 'Homebrew/Python pip is not found. Install `mackup` using one of these methods'
fi
### Remove temporary configuration files
rm -f ~/.mackup
rm -f ~/.mackup.cfg
{{ end }}