3

I would like to set and retrieve the custom keyboard shortcuts via commandline. I've found out how to set and restore the normal standard shortcuts using gconftool-2 (and navigatable via gconf-editor). I've also seen that apparently custom keyboard shortcuts are stored in dconf, though I'm skeptical.

In attempting to use dconf to write and read the settings, it doesn't seem like the tool is updating the same setting. Can anyone help me find and update these custom keyboard shortcuts?

What I tried in dconf:

  1. I set the shortcut:

    dconf write '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0' "'<Primary><Alt>p'"

  2. I checked by opening up the unity dash, and going to 'keyboard' and 'keyboard shortcuts'. It didn't seem to be set.
  3. Then I set my own shutcut on "custom0" to see if I used the wrong syntax. I set and cleared several times and called:

    dconf read '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0'

  4. Even though other keyboard shortcuts are set, custom0 was the only one that returned values.

Context: I'm trying to swap between pianobar and banshee multi-media keys. I found out about pianobar ctl's socket used for sending keyboard shortcuts. I switch between sometimes and it's tedious to open up the keyboard shortcuts each time to update them. I've already figured out how to set the multimedia keys via:

gconftool-2 --set '/apps/gnome_settings_daemon/keybindings/play' --type 'string' '<Primary><Alt>p'
gconftool-2 --set '/apps/gnome_settings_daemon/keybindings/play' --type 'string' ''

Edit (2014-12-18):

I wonder if I'm going about this wrong. It doesn't seem like keyboard -> shortcuts has many commandline options.

CCSM also handles capturing keyboard shortcuts, is that at all configurable via commandline?


Note related, but not duplicate questions:

2
  • For what it's worth, I've started doing something else here to solve my problem: gist.github.com/isaaclw/cbd3bf7bb13f5aefe987#file-multimedia-sh I check for the program that's running and then run a specific qdbus command to start/stop the program instead of worrying about swapping key-bindings.
    – isaaclw
    Oct 31, 2016 at 19:29
  • I could post it as an answer, but it's not really an answer to my specific question. It's just a different approach that others might find useful.
    – isaaclw
    Oct 31, 2016 at 19:30

1 Answer 1

2

To show all:

gsettings list-recursively  | grep --ignore-case "keys\|hotkey\|keybind"

To get:

gsettings get org.gnome.settings-daemon.plugins.media-keys calculator

To set:

gsettings set org.gnome.settings-daemon.plugins.media-keys calculator 'Hiragana'

For more info:

man gsettings

To easily get the values for "special" keys (multimedia, non-standard function keys):

xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'

All these are standard in any recent Ubuntu; no need to install any additional tools.

8
  • No thank you's needed, just accept the answer and upvote it (as I finally get to answer a question from a non-rep-1 user) >:)
    – Fabby
    Dec 16, 2014 at 23:34
  • Thanks for the help, this seems to be pointing a helpful direction, but I'm stumped again. I currently have a keybinding set: "<Ctrl><Alt>p" which is running /usr/local/bin/pianobar-ctl p I know it because it's happening. But I don't see any reference to it in gsettings list-recursively so I'll need some other tool I guess to toggle that setting.
    – isaaclw
    Dec 17, 2014 at 21:32
  • Actually looks like gsettings just loops back to dconf (which doesn't seem to work. gsettings list-recursively | grep custom0 sends me to /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0 which is what I tried to set with dconf, and didn't seem to have any effect.
    – isaaclw
    Dec 17, 2014 at 21:39
  • dconf uses the underlying gsettings, not the other way around. And gsettings will allow you to enter things you can not necessarily do in dconf. So in your particular case, you need to gsettings list-recursively | grep --ignore-case "alt+p\|alt>p" and then remove all the [Alt][P] stuff that you find and then assign it to your custom shortcut. If you post the output of the above command, I'll help you a bit further.
    – Fabby
    Dec 17, 2014 at 21:49
  • 1
    org.gnome.settings-daemon.plugins.media-keys window-screenshot '<Alt>Print' org.gnome.settings-daemon.plugins.media-keys window-screenshot '<Alt>Print'
    – isaaclw
    Dec 18, 2014 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .