80 lines
1.5 KiB
Shell
Executable file
80 lines
1.5 KiB
Shell
Executable file
#!/bin/sh
|
|
|
|
# Restore the Gnome settings from ~/.config/gnome-settings/*.ini
|
|
#
|
|
# `dconf load` merges into the existing state, implying
|
|
# that keys removed from the *.ini files would still be active
|
|
# => Reset the subtrees we fully manage first,
|
|
# which makes the resulting state deterministic
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
SETTINGS_DIR="$XDG_CONFIG_HOME/gnome-settings"
|
|
|
|
|
|
|
|
# Subtrees fully described by the *.ini files
|
|
RESET_PATHS="
|
|
/org/gnome/desktop/app-folders/
|
|
/org/gnome/desktop/wm/keybindings/
|
|
/org/gnome/mutter/keybindings/
|
|
/org/gnome/settings-daemon/plugins/media-keys/
|
|
/org/gnome/shell/extensions/
|
|
/org/gnome/shell/keybindings/
|
|
"
|
|
|
|
|
|
|
|
if ! command -v dconf >/dev/null 2>&1; then
|
|
echo "dconf is not installed => Nothing to do" >&2
|
|
exit 0
|
|
fi
|
|
|
|
|
|
if [ ! -d "$SETTINGS_DIR" ]; then
|
|
echo "No settings found at: $SETTINGS_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
|
|
|
|
echo "Backing up current GNOME settings to: /tmp/gnome-settings-backup.ini"
|
|
|
|
dconf dump / > /tmp/gnome-settings-backup.ini
|
|
|
|
|
|
|
|
echo "Resetting managed subtrees"
|
|
|
|
for path in $RESET_PATHS; do
|
|
echo " $path"
|
|
dconf reset -f "$path"
|
|
done
|
|
|
|
|
|
|
|
echo "Loading settings from: $SETTINGS_DIR"
|
|
|
|
for file in "$SETTINGS_DIR"/*.ini; do
|
|
[ -e "$file" ] || continue # because the glob does not expand if empty
|
|
echo " $(basename "$file")"
|
|
dconf load / < "$file"
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
echo "Log out and back in for all changes to take effect"
|
|
echo ""
|
|
|
|
|
|
|
|
printf "Log out now? [y/N] "
|
|
read -r answer
|
|
case "$answer" in
|
|
[Yy]*) gnome-session-quit --logout ;;
|
|
esac
|