I appear to be suffering from this bug that means my custom keyboard shortcuts are lost on reboot. I have 8 custom shortcuts, and re-setting all 8 via the GUI method for setting keyboard shortcuts is tedious.

I am using 12.10 and Unity. The keyboard shortcuts I want to customise are

  • "Shift to workspace left" (right/above/below) - with shortcut CtrlAltl (h/k/j)
  • "Move window one workspace to the left" (right/up/down) - with shortcut ShiftCtrlAltl (h/k/j).

(At least those are the names I see in the keyboard shortcut dialogs.)

So until the bug is fixed, I would like to be able to run a script to set all 8 after I have logged in. So what command line program and options do I need to run to set a keyboard shortcut?


I think you can achieve that effect using a script like this (only deals with switching desktop, but it can be extended changing switch-to-workspace* with move-to-workspace*):

gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-up "['<Control><Primary><Alt>k']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-down "['<Control><Primary><Alt>j']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "['<Control><Primary><Alt>h']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "['<Control><Primary><Alt>l']"

NOTE: Maybe the <Primary> part in shortcut is redundant. Try by yourself.

To automate the process you can also make this script run at startup, using the "Startup Applications" program.

  • Nice try, but the /apps/metacity/window_keybindings/switch_to_workspace_up doesn't seem to exist. I'm browsing around using dconf-editor to see where the shortcut might be. – Hamish Downer Nov 4 '12 at 18:29
  • 1
    @HamishDowner if you want to see it you must use gconf-editor – Salem Nov 4 '12 at 18:45
  • Turns out the gconf settings are actually all correct, but the keybindings still don't work :/ Time to go update the bug. – Hamish Downer Nov 4 '12 at 19:08
  • are you sure compiz/unity actually use gconf for these settings? – Hamish Downer Nov 4 '12 at 19:19
  • 3
    Hi thanks for the useful answer, to quickly search a shortcut path I've found useful the command: # dconf dump / | less (Lists everything) – user106924 Nov 10 '12 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.