Skip to content

Instantly share code, notes, and snippets.

@peterrus
Last active June 8, 2024 09:06
Show Gist options
  • Save peterrus/e59a96688a4d49ee3d9302c0d3ff5fdd to your computer and use it in GitHub Desktop.
Save peterrus/e59a96688a4d49ee3d9302c0d3ff5fdd to your computer and use it in GitHub Desktop.
Backs up and restores gnome3 keybindings
#!/usr/bin/env bash
# Backs up and restores gnome3 keybindings
# Tested with Gnome 3.36.8
# by peterrus
set -e
mkdir -p gnome3-keybind-backup
if [[ $1 == 'backup' ]]; then
dconf dump '/org/gnome/desktop/wm/keybindings/' > gnome3-keybind-backup/keybindings.dconf
dconf dump '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/' > gnome3-keybind-backup/custom-values.dconf
dconf read '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings' > gnome3-keybind-backup/custom-keys.dconf
echo "backup done"
exit 0
fi
if [[ $1 == 'restore' ]]; then
dconf reset -f '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/'
dconf reset -f '/org/gnome/desktop/wm/keybindings/'
dconf load '/org/gnome/desktop/wm/keybindings/' < gnome3-keybind-backup/keybindings.dconf
dconf load '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/' < gnome3-keybind-backup/custom-values.dconf
dconf write '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings' "$(cat gnome3-keybind-backup/custom-keys.dconf)"
echo "restore done"
exit 0
fi
echo "parameter 0: [backup|restore]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment