#!/bin/sh # Load the ~/.config/gnome-settings[/local]/*.ini files into `dconf`, # or just the single given as an argument # # Unlike ~/.local/bin/gnome-restore this neither backs up nor resets # anything, so keys removed from the *.ini files stay active # => Use this for a quick iteration on the *.ini files, # and `gnome-restore` for a deterministic state set -eu XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" GNOME_CFG_DIR="$XDG_CONFIG_HOME/gnome-settings" _usage() { echo "Usage: $(basename "$0") []" >&2 exit 1 } _load() { # The *.ini files are machine independent and use a placeholder /home/user echo " $(basename "$1")" sed "s|/home/user|$HOME|g" "$1" | dconf load / } if ! command -v dconf >/dev/null 2>&1; then echo "dconf is not installed" >&2 exit 1 fi [ "$#" -le 1 ] || _usage # A single file, e.g., while iterating on it if [ "$#" -eq 1 ]; then if [ ! -f "$1" ]; then echo "No such file: $1" >&2 exit 1 fi echo "Loading a single GNOME settings file:" _load "$1" exit 0 fi # Load all *.ini files in ~/.config/gnome-settings[/local]/ if [ ! -d "$GNOME_CFG_DIR" ]; then echo "No such directory: $GNOME_CFG_DIR" >&2 exit 1 fi echo "Loading GNOME settings from: $GNOME_CFG_DIR" for file in "$GNOME_CFG_DIR"/*.ini; do [ -e "$file" ] || continue # because the glob does not expand if empty _load "$file" done for file in "$GNOME_CFG_DIR"/local/*.ini; do [ -e "$file" ] || continue # because the glob does not expand if empty _load "$file" done