diff --git a/.config/gnome-settings/key-bindings.ini b/.config/gnome-settings/key-bindings.ini new file mode 100644 index 0000000..c84c368 --- /dev/null +++ b/.config/gnome-settings/key-bindings.ini @@ -0,0 +1,254 @@ +# Unify all key bindings in this file to conveniently keep them consistent + + +[org/gnome/desktop/wm/keybindings] + +# q is i3wm's default +close=['Q', 'Q', 'Q', 'F4'] + +maximize=@as [] +unmaximize=@as [] +toggle-maximized=['M'] +minimize=@as [] + +switch-applications=['Tab', 'Tab'] +switch-applications-backward=['Tab', 'Tab'] + +switch-input-source=@as [] +switch-input-source-backward=@as [] + +switch-group=@as [] +switch-group-backward=@as [] +switch-panels=@as [] +switch-panels-backward=@as [] + +cycle-group=@as [] +cycle-group-backward=@as [] +cycle-panels=@as [] +cycle-panels-backward=@as [] +cycle-windows=@as [] +cycle-windows-backward=@as [] + +begin-move=@as [] +begin-resize=@as [] + +# 1-5 is i3wm's default; the directional variants are cleared +# because forge uses Left/Right to swap windows +switch-to-workspace-1=['1', '1'] +switch-to-workspace-2=['2', '2'] +switch-to-workspace-3=['3', '3'] +switch-to-workspace-4=['4', '4'] +switch-to-workspace-5=['5', '5'] +switch-to-workspace-6=['6', '6'] +switch-to-workspace-7=['7', '7'] +switch-to-workspace-8=['8', '8'] +switch-to-workspace-9=['9', '9'] +switch-to-workspace-10=['0', '0'] +switch-to-workspace-last=@as [] +switch-to-workspace-left=@as [] +switch-to-workspace-right=@as [] + +# 1-5 is i3wm's default +move-to-workspace-1=['1', '1'] +move-to-workspace-2=['2', '2'] +move-to-workspace-3=['3', '3'] +move-to-workspace-4=['4', '4'] +move-to-workspace-5=['5', '5'] +move-to-workspace-6=['6', '6'] +move-to-workspace-7=['7', '7'] +move-to-workspace-8=['8', '8'] +move-to-workspace-9=['9', '9'] +move-to-workspace-10=['0', '0'] +move-to-workspace-last=@as [] +move-to-workspace-left=@as [] +move-to-workspace-right=@as [] + + +[org/gnome/mutter/keybindings] + +toggle-tiled-left=@as [] +toggle-tiled-right=@as [] + + +[org/gnome/settings-daemon/plugins/media-keys] + +email=['E'] +help=@as [] +home=['F'] +search=['slash'] +terminal=@as [] +www=['B'] + +screensaver=['Escape'] +logout=@as [] + +# Besides the numkeys, we use "/", ".", and "," to control the media +play=['Slash'] +next=['Right'] +previous=['Left'] +# Note: I often type "m" for "mute" intuitively +volume-mute=['M'] +volume-up=['Up'] +volume-down=['Down'] + +magnifier=@as [] +magnifier-zoom-in=@as [] +magnifier-zoom-out=@as [] + +on-screen-keyboard=@as [] +screenreader=@as [] + +custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom6/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom7/'] + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0] +binding='Home' +command='gnome-session-quit --reboot' +name='Reboot Machine' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1] +binding='End' +command='gnome-session-quit --power-off' +name='Shutdown Machine' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2] +binding='Delete' +command='gnome-session-quit --logout' +name='Log out (1)' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3] +binding='BackSpace' +command='gnome-session-quit --logout' +name='Log out (2)' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4] +binding='G' +command='google-chrome' +name='Google Chrome' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5] +# Mimic i3wm's default way to open terminals +binding='Return' +command='/usr/bin/alacritty' +name='Terminal (1)' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom6] +# Faster than the default t +binding='T' +command='/usr/bin/alacritty' +name='Terminal (2)' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom7] +# Gnome's actual default, but with a custom terminal emulator +binding='T' +command='/usr/bin/alacritty' +name='Terminal (3)' + + +[org/gnome/shell/extensions/forge/keybindings] + +mod-mask-mouse-tile='Super' + +# In [org/freedesktop/ibus/panel/emoji], "hotkey" must be "@as []" +# to turn GNOME's Emoji picker off, which also uses Period +prefs-open=['Period'] + +focus-border-toggle=@as [] +prefs-tiling-toggle=@as [] + +# Changing the gap size dynamically is not needed +window-gap-size-decrease=@as [] +window-gap-size-increase=@as [] + +workspace-active-tile-toggle=['Y'] + +window-toggle-float=['Y'] +window-toggle-always-float=@as [] + +window-focus-up=['k', 'Up'] +window-focus-down=['j', 'Down'] +window-focus-left=['h', 'Left'] +window-focus-right=['l', 'Right'] + +window-move-up=['k', 'Up'] +window-move-down=['j', 'Down'] +window-move-left=['h', 'Left'] +window-move-right=['l', 'Right'] + +window-swap-up=['k', 'Up'] +window-swap-down=['j', 'Down'] +window-swap-left=['h', 'Left'] +window-swap-right=['l', 'Right'] + +window-swap-last-active=['Return'] + +window-resize-top-increase=['k', 'Up'] +window-resize-top-decrease=['j', 'Down'] +window-resize-bottom-increase=['j', 'Down'] +window-resize-bottom-decrease=['k', 'Up'] +window-resize-left-increase=['h', 'Left'] +window-resize-left-decrease=['l', 'Right'] +window-resize-right-increase=['l', 'Right'] +window-resize-right-decrease=['h', 'Left'] + +window-snap-center=@as [] +window-snap-one-third-left=@as [] +window-snap-one-third-right=@as [] +window-snap-two-third-left=@as [] +window-snap-two-third-right=@as [] + +# Container stuff +con-split-horizontal=@as [] +con-split-vertical=@as [] +con-split-layout-toggle=@as [] +con-stacked-layout-toggle=@as [] +con-tabbed-layout-toggle=@as [] +con-tabbed-showtab-decoration-toggle=@as [] + + +[org/gnome/shell/extensions/nightthemeswitcher/time] + +nightthemeswitcher-ondemand-keybinding=['D'] + + +[org/gnome/shell/keybindings] + +focus-active-notification=@as [] +open-application-menu=@as [] + +# Disable Gnome's default behavior of opening "favorite" apps +# with 1-10 and instead switch workspaces +switch-to-application-1=@as [] +switch-to-application-2=@as [] +switch-to-application-3=@as [] +switch-to-application-4=@as [] +switch-to-application-5=@as [] +switch-to-application-6=@as [] +switch-to-application-7=@as [] +switch-to-application-8=@as [] +switch-to-application-9=@as [] +switch-to-application-10=@as [] + +toggle-message-tray=@as [] +toggle-overview=@as [] + + +[org/gnome/terminal/legacy/keybindings] + +close-tab='W' +close-window='Q' + +find='F' +find-clear='J' +find-next='N' +find-previous='H' + +new-tab='T' +new-window='N' + +zoom-in='Plus' +# default: zoom-out='minus' + + +# To avoid conflict with prefs-open in [org/gnome/shell/extensions/forge/keybindings] +[org/freedesktop/ibus/panel/emoji] +hotkey=@as [] diff --git a/.local/bin/restore-gnome b/.local/bin/restore-gnome new file mode 100755 index 0000000..90cebe9 --- /dev/null +++ b/.local/bin/restore-gnome @@ -0,0 +1,71 @@ +#!/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/notifications/ +/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 the current GNOME settings to: /tmp/gnome-settings-backup.ini" +dconf dump / > /tmp/gnome-settings-backup.ini + + + +echo "Resetting the managed subtrees" + +for path in $RESET_PATHS; do + echo " $path" + dconf reset -f "$path" +done + + +echo "Loading the 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 ""