Add configuration for GNOME
This commit is contained in:
parent
97420532e0
commit
c5f9769acf
24 changed files with 4188 additions and 0 deletions
147
.local/bin/restore-gnome
Executable file
147
.local/bin/restore-gnome
Executable file
|
|
@ -0,0 +1,147 @@
|
|||
#!/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}"
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
|
||||
|
||||
BACKUP_DIR="$XDG_STATE_HOME/gnome-settings-backups"
|
||||
SETTINGS_DIR="$XDG_CONFIG_HOME/gnome-settings"
|
||||
|
||||
|
||||
# Subtrees either
|
||||
# - fully described by the *.ini files
|
||||
# - or reset to their defaults
|
||||
#
|
||||
# Note: Keep in sync with the `grep`s in ~/.local/bin/verify-dconf
|
||||
RESET_PATHS="
|
||||
/ca/desrt/dconf-editor/
|
||||
/org/freedesktop/ibus/panel/
|
||||
/org/freedesktop/tracker/
|
||||
/org/gnome/baobab/
|
||||
/org/gnome/calculator/
|
||||
/org/gnome/calendar/
|
||||
/org/gnome/Characters/
|
||||
/org/gnome/clocks/
|
||||
/org/gnome/Connections/
|
||||
/org/gnome/Contacts/
|
||||
/org/gnome/control-center/
|
||||
/org/gnome/desktop/
|
||||
/org/gnome/Disks/
|
||||
/org/gnome/evince/
|
||||
/org/gnome/Extensions/
|
||||
/org/gnome/file-roller/
|
||||
/org/gnome/gedit/
|
||||
/org/gnome/gnome-system-monitor/
|
||||
/org/gnome/Loupe/
|
||||
/org/gnome/maps/
|
||||
/org/gnome/mutter/
|
||||
/org/gnome/nautilus/
|
||||
/org/gnome/nm-applet/
|
||||
/org/gnome/portal/
|
||||
/org/gnome/settings-daemon/
|
||||
/org/gnome/shell/
|
||||
/org/gnome/simple-scan/
|
||||
/org/gnome/software/
|
||||
/org/gnome/system/location/
|
||||
/org/gnome/terminal/
|
||||
/org/gnome/TextEditor/
|
||||
/org/gnome/Totem/
|
||||
/org/gnome/tweaks/
|
||||
/org/gnome/Weather/
|
||||
/org/gnome/GWeather4/
|
||||
/org/gtk/
|
||||
/system/
|
||||
"
|
||||
|
||||
|
||||
|
||||
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: $BACKUP_DIR"
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
dconf dump / > "$BACKUP_DIR/$(date +%Y%m%d-%H%M%S).ini"
|
||||
|
||||
# Keep the ten most recent backups
|
||||
# shellcheck disable=SC2012 # File names are timestamps => `ls` is safe
|
||||
ls -1t "$BACKUP_DIR"/*.ini | tail -n +11 | xargs -r rm --
|
||||
|
||||
|
||||
|
||||
echo "Resetting managed subtrees in dconf"
|
||||
|
||||
for path in $RESET_PATHS; do
|
||||
echo " $path"
|
||||
dconf reset -f "$path"
|
||||
done
|
||||
|
||||
|
||||
|
||||
# forge's `patchCss()` writes its stylesheet backup to a path built from a
|
||||
# property that no longer exists, yielding "~/undefined.bak"
|
||||
# => Patch the path in the installed extension
|
||||
THEME_JS="$XDG_DATA_HOME/gnome-shell/extensions/forge@jmmaranan.com/lib/shared/theme.js"
|
||||
if [ -w "$THEME_JS" ]; then
|
||||
sed -i 's|this\.configMgr\.stylesheetFileName + "\.bak"|configCss.get_path() + ".bak"|' "$THEME_JS"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "Import GNOME extensions' schemas"
|
||||
|
||||
SCHEMAS="$HOME/.local/bin/import-gnome-extension-schemas"
|
||||
if [ -x "$SCHEMAS" ]; then
|
||||
"$SCHEMAS" || echo "WARN: importing GNOME extension schemas failed" >&2
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "Loading GNOME 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")"
|
||||
sed "s|/home/user|$HOME|g" "$file" | dconf load /
|
||||
done
|
||||
|
||||
for file in "$SETTINGS_DIR"/local/*.ini; do
|
||||
[ -e "$file" ] || continue # because the glob does not expand if empty
|
||||
echo " $(basename "$file")"
|
||||
sed "s|/home/user|$HOME|g" "$file" | dconf load /
|
||||
done
|
||||
|
||||
|
||||
|
||||
echo "Patching forge"
|
||||
|
||||
# Draw a whitish border on unfocused windows as well
|
||||
|
||||
PATCH="$HOME/.local/bin/patch-forge"
|
||||
if [ -x "$PATCH" ]; then
|
||||
"$PATCH" || echo "WARN: forge border patch failed" >&2
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "Restored GNOME to the defaults defined in ~/.config/gnome-settings"
|
||||
Loading…
Reference in a new issue