Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

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*):

#!/bin/bash
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.

share|improve this answer
    
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
2  
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
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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