2023-01-09 16:06:45 -08:00
|
|
|
{{- if eq .host.distro.family "linux" -}}
|
|
|
|
#!/usr/bin/env bash
|
2023-04-11 20:26:25 -07:00
|
|
|
# @file DConf Settings
|
|
|
|
# @brief Applies repository-housed `dconf` settings.
|
|
|
|
# @description
|
|
|
|
# This script allows you to apply `dconf` settings that you can store in your fork of Install Doctor. By default,
|
|
|
|
# it makes a handful of `dconf` settings optimizations.
|
2023-01-09 16:06:45 -08:00
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
2023-01-24 05:08:53 -08:00
|
|
|
### Update background to be OS-specific
|
|
|
|
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/dconf/settings/org.gnome.desktop.background" ]; then
|
|
|
|
logg info 'Checking for presence of /usr/local/share/wallpapers/Betelgeuse-{{ title .host.distro.id }}/contents/source.jpg'
|
|
|
|
if [ -f /usr/local/share/wallpapers/Betelgeuse-{{ title .host.distro.id }}/contents/source.jpg ]; then
|
|
|
|
logg info "Updating ${XDG_CONFIG_HOME:-$HOME/.config}/dconf/settings/org.gnome.desktop.background to point to OS-specific background"
|
|
|
|
TMP="$(mktemp)"
|
|
|
|
sed 's/Betelgeuse/Betelgeuse-{{ title .host.distro.id }}/g' < "${XDG_CONFIG_HOME:-$HOME/.config}/dconf/settings/org.gnome.desktop.background" > "$TMP"
|
|
|
|
mv "$TMP" "${XDG_CONFIG_HOME:-$HOME/.config}/dconf/settings/org.gnome.desktop.background"
|
|
|
|
else
|
|
|
|
logg info 'OS-specific background not found'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-01-09 16:06:45 -08:00
|
|
|
### Backup system settings
|
|
|
|
DCONF_TMP="$(mktemp)"
|
|
|
|
dconf dump / > "$DCONF_TMP"
|
|
|
|
logg info 'Backed up system dconf settings to '"$DCONF_TMP"
|
|
|
|
|
|
|
|
### Reset system settings / load saved configurations from ~/.config/dconf/settings
|
2023-08-07 22:29:21 -07:00
|
|
|
if [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/dconf/settings" ]; then
|
|
|
|
find "${XDG_CONFIG_HOME:-$HOME/.config}/dconf/settings" -mindepth 1 -maxdepth 1 -type f | while read DCONF_CONFIG_FILE; do
|
2023-01-10 02:07:53 -08:00
|
|
|
if [ "$DEBUG_MODE" == 'true' ]; then
|
|
|
|
logg info 'Dconf configuration file:'
|
|
|
|
echo "$DCONF_CONFIG_FILE"
|
|
|
|
fi
|
2023-01-24 03:50:09 -08:00
|
|
|
DCONF_SETTINGS_ID="/$(basename "$DCONF_CONFIG_FILE" | sed 's/\./\//g')/"
|
2023-01-10 02:07:53 -08:00
|
|
|
if [ "$DEBUG_MODE" == 'true' ]; then
|
2023-01-10 02:09:23 -08:00
|
|
|
logg info 'Dconf settings ID:'
|
|
|
|
echo "$DCONF_SETTINGS_ID"
|
2023-01-10 02:07:53 -08:00
|
|
|
fi
|
2023-01-09 16:06:45 -08:00
|
|
|
# Reset dconf settings if environment variable RESET_DCONF is set to true
|
|
|
|
if [ "$RESET_DCONF" == 'true' ]; then
|
2023-11-04 18:46:18 -07:00
|
|
|
logg info 'Resetting dconf settings for '"$DCONF_SETTINGS_ID"''
|
2023-01-09 16:06:45 -08:00
|
|
|
dconf reset -f "$DCONF_SETTINGS_ID"
|
|
|
|
fi
|
2023-11-04 18:46:18 -07:00
|
|
|
logg info 'Loading versioned dconf settings for '"$DCONF_SETTINGS_ID"''
|
2023-01-09 16:06:45 -08:00
|
|
|
dconf load "$DCONF_SETTINGS_ID" < "$DCONF_CONFIG_FILE"
|
2023-11-04 18:46:18 -07:00
|
|
|
logg success 'Finished applying dconf settings for '"$DCONF_SETTINGS_ID"''
|
2023-01-09 16:06:45 -08:00
|
|
|
done
|
|
|
|
else
|
|
|
|
logg warn '~/.config/dconf/settings does not exist!'
|
|
|
|
fi
|
|
|
|
|
|
|
|
{{ end -}}
|