Automate Gnome keybindings

Sick of manual GUI twiddling to fix inconsistent keybindings on various computers. Solved once and for all, by a new script in my personal workstation setup bucket:

Warning: This works great on RHEL, but doesn’t all work on Ubuntu, I suspect because Unity has it’s own set of keybinds that are defined elsewhere.

#!/usr/bin/env bash
# Switcher, between windows not apps, uses alt-tab and alt-grave
gsettings set $kb switch-windows "['<Alt>Tab']"
gsettings set $kb switch-windows-backward "['<Alt>grave', '<Shift><Alt>Tab']"
gsettings set $kb switch-applications "[]"
gsettings set $kb switch-applications-backward "[]"
# Window maximize toggle, super-up
gsettings set $kb maximize "['<Super>Up']"
# Window maximize vertically toggle, super-v
gsettings set $kb maximize-vertically "['<Super>v']"
# run command, super-r
gsettings set $kb panel-run-dialog "['<Super>r', '<Alt>F2']"
# Custom commands
gsettings set $mk custom-keybindings "['$ckb/custom0/', '$ckb/custom1/']"
gsettings set $mk.custom-keybinding:$ckb/custom0/ name "screen off"
gsettings set $mk.custom-keybinding:$ckb/custom0/ command "screenoff"
gsettings set $mk.custom-keybinding:$ckb/custom0/ binding "<Super>z"
gsettings set $mk.custom-keybinding:$ckb/custom1/ name "terminal"
gsettings set $mk.custom-keybinding:$ckb/custom1/ command "terminal"
gsettings set $mk.custom-keybinding:$ckb/custom1/ binding "<Super>t"

Embedded in that is the ultimate solution to my longstanding irk with Unity and Gnome’s default window switcher (alt-tab.) By default it groups windows of a single application together, requiring some extra -grave pressing to navigate between windows within an application.

This not only requires way more effort, but also breaks the expected behaviour of just tapping alt-tab to go back to the last used window. Instead it goes back to the last used application, so you can’t toggle between two windows of the same application, eg. two terminals. Absolute madness.

The above modifies alt-tab to just cycle through all windows, ungrouped, which fixes the ability to toggle between last two windows. Also, alt-grave is provided as an alternative to cycle backwards through the windows, which is easier to hit than shift-alt-tab.

Leave a Reply