Implement the ipc 'binding' event

The binding event will be triggered when a binding is run as a result of
some a user action. The binding event has the following properties:

change: (str) Currently this will only be "run" but may be expanded in
the future. Included for consistency with other events.

binding: (map) the serialized binding

The "binding" member will have these properties:

input_type: (str) either "keyboard" or "mouse"

input_code: (int) the xcb keycode of the keyboard binding if it was
provided or the mouse button if it is a mouse binding.

symbol: (str) the string representation of the input code

command: (str) the bound command

mods: (list of str) a list of the modifiers that were pressed as string
symbols

fixes #1210
This commit is contained in:
Tony Crisci
2014-10-02 19:04:53 -04:00
committed by Michael Stapelberg
parent 3cf413492f
commit fbaf084426
6 changed files with 221 additions and 2 deletions

View File

@ -1,7 +1,7 @@
IPC interface (interprocess communication)
==========================================
Michael Stapelberg <michael@i3wm.org>
February 2014
October 2014
This document describes how to interface with i3 from a separate process. This
is useful for example to remote-control i3 (to write test cases for example) or
@ -638,6 +638,9 @@ window (3)::
barconfig_update (4)::
Sent when the hidden_state or mode field in the barconfig of any bar
instance was updated and when the config is reloaded.
binding (5)::
Sent when a configured command binding is triggered with the keyboard or
mouse
*Example:*
--------------------------------------------------------------------
@ -749,6 +752,47 @@ This event consists of a single serialized map reporting on options from the
barconfig of the specified bar_id that were updated in i3. This event is the
same as a +GET_BAR_CONFIG+ reply for the bar with the given id.
=== binding event
This event consists of a single serialized map reporting on the details of a
binding that ran a command because of user input. The +change (sring)+ field
indicates what sort of binding event was triggered (right now it will always be
+"run"+ but may be expanded in the future).
The +binding (object)+ field contains details about the binding that was run:
command (string)::
The i3 command that is configured to run for this binding.
mods (array of strings)::
The modifier keys that were configured with this binding.
input_code (integer)::
If the binding was configured with +bindcode+, this will be the key code
that was given for the binding. If the binding is a mouse binding, it will be
the number of the mouse button that was pressed. Otherwise it will be 0.
symbol (string)::
If this is a keyboard binding that was configured with +bindsym+, this
field will contain the given symbol.
input_type (string)::
This will be +"keyboard"+ or +"mouse"+ depending on whether or not this was
a keyboard or a mouse binding.
*Example:*
---------------------------
{
"change": "run",
"binding": {
"command": "nop",
"mods": [
"shift",
"ctrl"
],
"input_code": 0,
"symbol": "t",
"input_type": "keyboard"
}
}
---------------------------
== See also (existing libraries)
[[libraries]]