1

This answer by Jacob Vlijm is an excellent guide to those wishing to add custom keybindings en masse, via the command line.

There are limits, however, to what's accepted as a valid binding. Shift+p for example, is something that you can absolutely set a custom keybinding to, but it won't actually function. For a custom binding to qualify as valid (and so perform the command when pressed), I believe the binding needs to contain Primary (Control) and/or Alt (plus some normal key, like k). Also, I'm not certain whether a binding can be made to distinguish between left and right; I suspect it can't. I suspect there is no Shift_L or Alt_R, but I'm not certain on that, and hope to be wrong.

Is there a known alternative to dconf's key binding functionality? dconf is perfectly fine for nearly all cases and users, I expect; I'm just being difficult and so want to know.

1

There are alternatives to dconf's binding functionality if you run Gnome on X-server. You could use xbindkeys or sxhkd, daemons that are configured using a text file, and can be loaded automatically on log in. Both will work well in Gnome running on X, but may not work on Wayland.

You can assign your custom commands to Shift+key keys. However, these utilities do not allow to discriminate between left and right modifier keys.

  • Thank you very much for replying. It's going to take me a little while to put your advice to use, as I'm super noob over here, but I will research until I understand it. If I may ask a follow-up: do you personally have Gnome running on X, and if so, can you verify whether it's possible to use xbindkeys or sxhkd to create a custom keybinding for, for example, '<Shift_R>k', such that pressing Right Shift + k will execute the command, while Left Shift + k will not? If you don't know and aren't inclined to check, that's fine; I just thought I'd ask, in case you already know the answer. – John R Oct 4 '19 at 16:04
  • In that case, I suggest you start with sxhkd, which is more current and has a much nicer and accessible keyboard syntax. I am not using it myself, so I cannot test, but I would be glad to hear your feedback on whether it actually works for that particular key combination. – vanadium Oct 4 '19 at 16:12
  • I quickly checked with sxhkd, and also these utilities unfortunatelly do not allow to differentiate between a left and a right modifier key. However, there is no problem assigning any key you want. You can find the keysymbol with the tool xev or in the file /usr/include/X11/keysym.h – vanadium Oct 4 '19 at 16:29
  • Indeed, confirm also for xbindkeys: the command "xbindkeys --key" returns the same code for both left and right shift d – vanadium Oct 4 '19 at 16:32
  • Dang. Well, that's alright. As I admitted before, I'm just being difficult, and this has been chased far enough. It looks to be a hard limit, so I need to change my expectation instead. Thanks very much for the many replies. You've been very helpful, and hopefully this exchange will keep somebody else from heading down the same rabbithole. – John R Oct 4 '19 at 16:53

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.