2019-07-18 16:45:46 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-07-18 17:42:05 +00:00
|
|
|
set -e
|
|
|
|
|
2020-01-19 18:33:39 +00:00
|
|
|
copy_dotfiles()
|
2019-07-18 17:42:05 +00:00
|
|
|
{
|
|
|
|
echo "[INFO] Installing dot files..."
|
|
|
|
|
|
|
|
rsync --exclude "dconf/" \
|
|
|
|
--exclude ".vscode/" \
|
2019-07-19 15:54:08 +00:00
|
|
|
--exclude ".git*" \
|
2019-07-18 17:42:05 +00:00
|
|
|
--exclude "install.sh" \
|
|
|
|
--exclude "LICENSE" \
|
|
|
|
--exclude "README.md" \
|
2019-10-04 17:17:27 +00:00
|
|
|
-hlav --no-perms . ~
|
2019-07-18 17:42:05 +00:00
|
|
|
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2019-11-17 16:29:34 +00:00
|
|
|
dconf_loader()
|
2019-07-18 17:42:05 +00:00
|
|
|
{
|
2019-11-17 16:29:34 +00:00
|
|
|
if ! command -v dconf > /dev/null 2>&1; then
|
2019-07-18 17:42:05 +00:00
|
|
|
echo "[WARNING] dconf command not found"
|
|
|
|
echo ""
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
for file in dconf/*; do
|
2019-11-17 16:29:34 +00:00
|
|
|
echo "[INFO] Loading $(basename "$file") config..."
|
|
|
|
dconf_path=$(grep -E -m1 '^#.+dconf-path=.+$' "$file" | cut -f2 -d "=")
|
|
|
|
dconf load "$dconf_path" < "$file"
|
2019-07-18 17:42:05 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2020-01-19 18:33:39 +00:00
|
|
|
dconf_dumper()
|
|
|
|
{
|
|
|
|
if ! command -v dconf > /dev/null 2>&1; then
|
|
|
|
echo "[WARNING] dconf command not found"
|
|
|
|
echo ""
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
for file in dconf/*; do
|
|
|
|
dconf_conf=$(grep -E -m1 '^#.+dconf-path=.+$' "$file")
|
|
|
|
dconf_path=$(echo "$dconf_conf" | cut -f2 -d "=")
|
|
|
|
|
|
|
|
echo "[INFO] Dumping $dconf_path to $(basename "$file")..."
|
|
|
|
printf "%s\n\n" "$dconf_conf" > "$file"
|
|
|
|
dconf dump "$dconf_path" >> "$file"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2019-11-17 16:29:34 +00:00
|
|
|
main()
|
2019-07-18 17:42:05 +00:00
|
|
|
{
|
2019-11-17 16:29:34 +00:00
|
|
|
cd "$(dirname "$0")"
|
2019-07-18 17:42:05 +00:00
|
|
|
|
2020-01-19 18:33:39 +00:00
|
|
|
if [ x"$1" = x"--dump-dconf" ]; then
|
|
|
|
dconf_dumper
|
|
|
|
else
|
|
|
|
copy_dotfiles
|
|
|
|
dconf_loader
|
|
|
|
fi
|
2019-07-18 17:42:05 +00:00
|
|
|
|
|
|
|
cd - > /dev/null
|
|
|
|
}
|
|
|
|
|
2020-01-19 18:33:39 +00:00
|
|
|
main "$1"
|
2019-07-18 16:45:46 +00:00
|
|
|
|