43

Is there a place in "Ubuntu" that stores a complete list of what keys/combinations/shortcuts are bound to what?

What are Unity's keyboard and mouse shortcuts? list some "Unity" shortcuts to the Dash, Launcher, etc. and How to list Compiz keybindings in use? shows a way to list compiz bindings, but I'm looking for more than that (not just a few of the keybindings limited only to Unity or Compiz) although it's a start.

Is there a global list of key bindings/key combinations/keyboard Shortcuts in use, that is stored somewhere in Ubuntu or is there a way to compile and list them? One that applies to Ubuntu and things running in it (Unity, Compiz, Shortcuts to Programs, etc.).

Surely, Ubuntu must store this somewhere for the key combination pressed on the keyboard to be directed to what it's connected with? If there is no such place in Ubuntu, then post so as an answer, so future users, that search, will know.

3
  • 1
    Ok I've retitled it to be less duplicate-y Feb 4, 2012 at 0:16
  • Two answers so far have brought up two conflicting sequences of events. Lakritsbollar stated the Window manager gets control first and then passes it down to applications, nfirvine stated applications get first crack at it then pass it up to Window manager. Which way is it?
    – James
    Feb 13, 2012 at 3:25
  • A few more shortcuts can be found at detector-pro.com/2008/07/ubuntu-tweak-keyboard-shortcuts.html
    – James
    Feb 25, 2012 at 19:29

5 Answers 5

26

Since Ubuntu 17.10

On this paths:

dconf dump /org/gnome/desktop/wm/keybindings/
dconf dump /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/  # Custom

You can also use dconf-editor (GUI) or gsettings (CLI).

Since Ubuntu 12.10-17.04

~/.config/dconf/user (in dconf-editor: org.gnome.settings-daemon.plugins.media-keys.custom-keybindings (custom shortcuts)

~/.config/compiz-1/compizconfig

Until Ubuntu 12.04

The shortcuts are placed differently depending on witch desktop you are using (gnome/unity, kde, xfce, lxde,etc).

For gnome, they are under
~/.gconf/desktop/gnome/keybindings (custom shortcuts)

and under
~/.gconf/apps/metacity.

8
  • 11.10 doesn't use GNOME or Metacity.
    – nfirvine
    Feb 11, 2012 at 3:04
  • But the path to shortcuts still works as I use it.
    – desgua
    Feb 11, 2012 at 23:46
  • When looking ate pretty fresh ubuntu 11.10 install on a macbook pro, the first location did not have the keybinding file but the second location had this: general/ global_keybindings/ window_keybindings/
    – Victor S
    Feb 17, 2012 at 8:18
  • 1
    The first location is for custom shortcuts.
    – desgua
    Feb 17, 2012 at 21:18
  • 1
    @AnonymousPlatypus see here for gsettings instructions
    – wjandrea
    May 4, 2016 at 17:51
13
+50

Your window manager gets the any key events before applications do, so if it wants to consume those events, it does so and your applications will never receive them. If the window manager does not want to react to the key events itself, it passes them along to the application.

You can verify this by yourself in the following way:

  1. Start a terminal.
  2. Start xev | grep KeyPress, the X event viewer.
  3. Press Alt, note that xev shows that it got the key event in its terminal window.
  4. Press Ctrl, again note that xev got the event. Take note of what the terminal window looks like right now.
  5. Press Left arrow to go to another workspace. (I'm assuming you have that as a window manager shortcut key.)
  6. Press Right arrow to go back to where you are running xev. Note that it never received any key events for you switching workspaces via left and right arrow keys -- the output is the same as it was in Step 4.

So you see that the window manager in practice gets all key events and if it does not want to capture them, it passes them along to the application. The application then gets to do the same for its own widgets (like how you can press Enter all day long in your web browser but it won't do anything until you put the cursor in the address bar or some field where you can enter text).

It is up to the application to set its own shortcuts, and applications are configured independently of each other.

In KDE 3.x, if I recall correctly, you could set the default shortcuts (e.g. Ctrl-s for save) in the KDE Control Center and it would apply to all applications written with the Qt toolkit, but I don't know if that's still possible since their switch to KDE 4.

1
  • It's not a 100% answer, but it's the close. Basically there is no central place where keyboard bindings/shortcuts are stored. Window manager gets first crack at key presses and then active applications. Focus also plays a part.
    – James
    Feb 14, 2012 at 12:26
4

No, there is no single place where all shortcuts are stored. Applications can choose to store their configurations wherever they choose.

That said, you're mostly looking at two levels: the application level (like Ctrl-C for copy in Firefox), and the window manager level (like Win+D to show the desktop). Compiz uses gconf to store its configuration.

For applications, you can roughly divide them by their toolkits. Namely, GTK apps use gconf too.

Surely, Ubuntu must store this somewhere for the key combination pressed on the keyboard to be directed to what it's connected with?

Not quite. The focussed application gets first kick at an X keyboard event, but if it doesn't, it bubbles up to other applications, namely the window manager. Thus, you can have a game that captures Alt+F4 and doesn't close the window (damn you, Jamestown!). I think you're thinking it goes to some central event router, then matched against some database, and routed to its destination. It's more like passing a bottle of drink around: pass, take a swig if you want and pass the rest, or take the whole thing and be greedy.

The Linux/FOSS environment (you may have noticed) is pretty democratic, and getting all applications to agree on a single central keyboard configuration repository is a fool's errand. For one thing, you've got unmaintained applications that were written a long time ago and wouldn't know about it.

Update: According to the Xlib docs on the subject:

Starting with the source window, the X server searches up the window hierarchy until it locates the first window specified by a client as having an interest in these events. If one of the intervening windows has its do-not-propagate-mask set to prohibit generation of the event type, the events of those types will be suppressed.

Also,

To receive KeyPress , KeyRelease , ButtonPress , and ButtonRelease events, set KeyPressMask, KeyReleaseMask, ButtonPressMask, and ButtonReleaseMask bits in the event-mask attribute of the window.

And you can set an attribute to disable propagation.

The problem is, you don't tell X which keys to listen for, so you can never tell a priori what keys the application listens for (let alone what they do) or really whether they intend to propagate it up if they are in fact listening for it. Thus, a central registry is impossible at the X level, so you'd have to do it at the toolkit level, which is merely practically impossible. :D

3
  • I have come to pretty much the same conclusion, that focus determines what handles input. Such can be observed by opening a browser window, then opening a terminal window which now becomes the active window. If you hold the mouse over the browser window then use the scroll wheel it will scroll the browser window even though the Terminal window is the active window.
    – James
    Feb 13, 2012 at 3:10
  • I had hoped for an easy answer to my question, or at least an easy way to compile and list the shortcuts, but it doesn't seem possible given the way key-presses eventually get to where they are defined. The keyboard shortcuts/keybindings seem to be spread out all over and their use tends to be dependent on what's active and where current focus is.
    – James
    Feb 13, 2012 at 3:16
  • 1
    However, I'm not with you on the application getting the key event before the window manager. I think the Window Manager has first crack at the event and then active applications.
    – James
    Feb 14, 2012 at 12:24
1

Applications store their shortcuts independently, so there is no central place, where they are stored.

I don't understand the whole process of the interaction keyboard--OS--kernel--X11--Window Manager--Desktop Environment--Applications, but if a certain window, like Gedit, has the keyboard focus, it can handle the input on its own, and it does so.

-1

In 11.10, under System Configuration -> Keyboard -> Shortcuts you get a pretty big list of them. Is that what you are looking for?

1
  • He's looking for the file which contains all of the shortcuts, not just a list of them. Jan 30, 2016 at 12:37

You must log in to answer this question.

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