install.fairie/home/dot_local/bin/executable_backup-apps.tmpl

39 lines
1.7 KiB
Cheetah
Raw Normal View History

#!/usr/bin/env bash
# @file ~/.local/bin/backup-apps
# @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" }}
if command -v mackup > /dev/null; then
2023-12-24 22:50:02 -08:00
### Create symlinks pointing to stored configurations
logg info 'Symlinking ~/.mackup and ~/.mackup.cfg'
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup/" ~/.mackup
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup.cfg" ~/.mackup.cfg
2023-12-24 22:50:02 -08:00
### Run mackup
logg info 'Running mackup'
mackup $* || echo ''
2023-12-24 22:50:02 -08:00
### Remove temporary configuration files
logg info 'Removing symlinked ~/.mackup and ~/.mackup.cfg configurations'
rm -f ~/.mackup
rm -f ~/.mackup.cfg
2023-12-24 22:50:02 -08:00
### Print success message
logg success 'Successfully ran backup-apps'
else
2023-12-24 22:50:02 -08:00
logg error 'mackup is not installed' && exit 1
fi