When I tried to list the available custom keybindings using gsettings command

gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings

I got the error message saying,

No such key 'custom-keybindings'

I graphically checked my custom keyboard shortcuts and it was empty. So I thought this is normal. So I tried to add new keybinding using

gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']"

Again the same error returned. I am using Ubuntu 12.04 in virtualbox. Doesn't it comes with the key custom-keybindings? How can I add a new custom-keybindingusing gsettings?

  • possible duplicate of How to set custom keyboard shortcuts from terminal? – Sylvain Pineau Mar 31 '15 at 7:33
  • This is not duplicate. I know how to set shortcuts using gsettings. But the problem is I cannot find the key custom-keybindings in Ubuntu 12.04. Is that a bug? I was able to locate it in 14.04 but not in 12.04. Where the keybinding files are actually stored in 12.04? – Anonymous Platypus Mar 31 '15 at 7:40
  • 1
    Until (and including) 12.04, custom keybindings are not stored in the dconf database, but in ~/.gconf/desktop/gnome/keybindings (in subfolders like custom0 etc). It is an xml file. See: askubuntu.com/a/101248/72216 – Jacob Vlijm Mar 31 '15 at 8:12
  • 1
    @AnonymousPlatypus I tried that, and it works, if the folder is named correctly, the file is correct and... after a log out / in. It can be scripted of course :) – Jacob Vlijm Mar 31 '15 at 9:11
  • 1
    I added a 12.04 specific script to create custom shortcuts. – Jacob Vlijm Mar 31 '15 at 12:08

Jacob Vlijm's python script was very useful. I am sharing a shell script to do this if someone may find it useful.

ls -d ~/.gconf/desktop/gnome/keybindings/*/
    if [[ `echo $?` == 2 ]]; then
        shortCutNumber=$((`ls -d ~/.gconf/desktop/gnome/keybindings/*/ | tail -c 3 | head -c 1`+1))
    echo -e '<?xml version="1.0"?>' > %gconf.xml 
    echo -e '\t<gconf>' | tee -a %gconf.xml 
    echo -e '\t<entry name="action" mtime="`date +%s`" type="string">' | tee -a %gconf.xml 
    echo -e '\t\t<stringvalue>gnome-terminal -e '`pwd`/LanChat.sh'</stringvalue>' | tee -a %gconf.xml 
    echo -e '\t</entry>' | tee -a %gconf.xml 
    echo -e '\t<entry name="name" mtime="`date +%s`" type="string">' | tee -a %gconf.xml 
    echo -e '\t\t<stringvalue>QryptoChat</stringvalue>' | tee -a %gconf.xml 
    echo -e '\t</entry>' | tee -a %gconf.xml
    echo -e '\t<entry name="binding" mtime="`date +%s`" type="string">' | tee -a %gconf.xml 
    echo -e '\t\t<stringvalue>&lt;Alt&gt;q</stringvalue>' | tee -a %gconf.xml 
    echo -e '\t</entry>' | tee -a %gconf.xml 
    echo -e '</gconf>' | tee -a %gconf.xml 
    mkdir ~/.gconf/desktop/gnome/keybindings/custom$shortCutNumber
    mv %gconf.xml ~/.gconf/desktop/gnome/keybindings/custom$shortCutNumber/

The script first checks whether there exists any custom shortcuts already. And then creates the %gconf.xml file inside a new custom folder with the necessary settings.

| improve this answer | |

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.