]> git.sur5r.net Git - i3/i3.github.io/blob - docs/ipc.html
update docs for 4.14
[i3/i3.github.io] / docs / ipc.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"\r
2     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
4 <head>\r
5 <link rel="icon" type="image/x-icon" href="/favicon.ico">\r
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />\r
7 <meta name="generator" content="AsciiDoc 8.6.9" />\r
8 <title>i3: IPC interface (interprocess communication)</title>\r
9 <link rel="stylesheet" href="/css/style.css" type="text/css" />\r
10 <link rel="stylesheet" href="/css/xhtml11.css" type="text/css" />\r
11 <script type="text/javascript">\r
12 /*<![CDATA[*/\r
13 document.addEventListener("DOMContentLoaded", function(){asciidoc.footnotes(); asciidoc.toc(2);}, false);\r
14 /*]]>*/\r
15 </script>\r
16 <script type="text/javascript" src="/js/asciidoc-xhtml11.js"></script>\r
17 </head>\r
18 <body class="article">\r
19 \r
20         <div id="main">\r
21             <a href="/"><h1 id="title">i3 - improved tiling WM</h1></a>\r
22                         <ul id="nav">\r
23                                 <li><a style="border-bottom: 2px solid #fff" href="/docs">Docs</a></li>\r
24                                 <li><a href="/screenshots">Screens</a></li>\r
25                                 <li><a href="https://www.reddit.com/r/i3wm/">FAQ</a></li>\r
26                                 <li><a href="/contact">Contact</a></li>\r
27                                 <li><a href="https://github.com/i3/i3/issues">Bugs</a></li>\r
28                         </ul>\r
29         <br style="clear: both">\r
30 <div id="content">\r
31 <div id="header">\r
32 <h1>IPC interface (interprocess communication)</h1>\r
33 <span id="author">Michael Stapelberg</span><br />\r
34 <span id="email"><tt>&lt;<a href="mailto:michael@i3wm.org">michael@i3wm.org</a>&gt;</tt></span><br />\r
35 <span id="revdate">October 2014</span>\r
36 <div id="toc">
37   <div id="toctitle">Table of Contents</div>
38   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
39 </div>\r
40 </div>\r
41 <div id="preamble">\r
42 <div class="sectionbody">\r
43 <div class="paragraph"><p>This document describes how to interface with i3 from a separate process. This\r
44 is useful for example to remote-control i3 (to write test cases for example) or\r
45 to get various information like the current workspaces to implement an external\r
46 workspace bar.</p></div>\r
47 <div class="paragraph"><p>The method of choice for IPC in our case is a unix socket because it has very\r
48 little overhead on both sides and is usually available without headaches in\r
49 most languages. In the default configuration file, the ipc-socket gets created\r
50 in <tt>/tmp/i3-%u.XXXXXX/ipc-socket.%p</tt> where <tt>%u</tt> is your UNIX username, <tt>%p</tt> is\r
51 the PID of i3 and XXXXXX is a string of random characters from the portable\r
52 filename character set (see mkdtemp(3)). You can get the socketpath from i3 by\r
53 calling <tt>i3 --get-socketpath</tt>.</p></div>\r
54 <div class="paragraph"><p>All i3 utilities, like <tt>i3-msg</tt> and <tt>i3-input</tt> will read the <tt>I3_SOCKET_PATH</tt>\r
55 X11 property, stored on the X11 root window.</p></div>\r
56 <div class="admonitionblock">\r
57 <table><tr>\r
58 <td class="icon">\r
59 <div class="title">Warning</div>\r
60 </td>\r
61 <td class="content">\r
62 <div class="title">Use an existing library!</div>There are existing libraries for many languages. You can have a look at\r
63 <a href="#libraries">[libraries]</a> or search the web if your language of choice is not mentioned.\r
64 Usually, it is not necessary to implement low-level communication with i3\r
65 directly.</td>\r
66 </tr></table>\r
67 </div>\r
68 </div>\r
69 </div>\r
70 <div class="sect1">\r
71 <h2 id="_establishing_a_connection">1. Establishing a connection</h2>\r
72 <div class="sectionbody">\r
73 <div class="paragraph"><p>To establish a connection, simply open the IPC socket. The following code\r
74 snippet illustrates this in Perl:</p></div>\r
75 <div class="listingblock">\r
76 <div class="content">\r
77 <pre><tt>use IO::Socket::UNIX;\r
78 chomp(my $path = qx(i3 --get-socketpath));\r
79 my $sock = IO::Socket::UNIX-&gt;new(Peer =&gt; $path);</tt></pre>\r
80 </div></div>\r
81 </div>\r
82 </div>\r
83 <div class="sect1">\r
84 <h2 id="_sending_messages_to_i3">2. Sending messages to i3</h2>\r
85 <div class="sectionbody">\r
86 <div class="paragraph"><p>To send a message to i3, you have to format in the binary message format which\r
87 i3 expects. This format specifies a magic string in the beginning to ensure\r
88 the integrity of messages (to prevent follow-up errors). Following the magic\r
89 string comes the length of the payload of the message as 32-bit integer, and\r
90 the type of the message as 32-bit integer (the integers are not converted, so\r
91 they are in native byte order).</p></div>\r
92 <div class="paragraph"><p>The magic string currently is "i3-ipc" and will only be changed when a change\r
93 in the IPC API is done which breaks compatibility (we hope that we don’t need\r
94 to do that).</p></div>\r
95 <div class="paragraph"><p>Currently implemented message types are the following:</p></div>\r
96 <div class="dlist"><dl>\r
97 <dt class="hdlist1">\r
98 COMMAND (0)\r
99 </dt>\r
100 <dd>\r
101 <p>\r
102         The payload of the message is a command for i3 (like the commands you\r
103         can bind to keys in the configuration file) and will be executed\r
104         directly after receiving it.\r
105 </p>\r
106 </dd>\r
107 <dt class="hdlist1">\r
108 GET_WORKSPACES (1)\r
109 </dt>\r
110 <dd>\r
111 <p>\r
112         Gets the current workspaces. The reply will be a JSON-encoded list of\r
113         workspaces (see the reply section).\r
114 </p>\r
115 </dd>\r
116 <dt class="hdlist1">\r
117 SUBSCRIBE (2)\r
118 </dt>\r
119 <dd>\r
120 <p>\r
121         Subscribes your connection to certain events. See <a href="#events">[events]</a> for a\r
122         description of this message and the concept of events.\r
123 </p>\r
124 </dd>\r
125 <dt class="hdlist1">\r
126 GET_OUTPUTS (3)\r
127 </dt>\r
128 <dd>\r
129 <p>\r
130         Gets the current outputs. The reply will be a JSON-encoded list of outputs\r
131         (see the reply section).\r
132 </p>\r
133 </dd>\r
134 <dt class="hdlist1">\r
135 GET_TREE (4)\r
136 </dt>\r
137 <dd>\r
138 <p>\r
139         Gets the layout tree. i3 uses a tree as data structure which includes\r
140         every container. The reply will be the JSON-encoded tree (see the reply\r
141         section).\r
142 </p>\r
143 </dd>\r
144 <dt class="hdlist1">\r
145 GET_MARKS (5)\r
146 </dt>\r
147 <dd>\r
148 <p>\r
149         Gets a list of marks (identifiers for containers to easily jump to them\r
150         later). The reply will be a JSON-encoded list of window marks (see\r
151         reply section).\r
152 </p>\r
153 </dd>\r
154 <dt class="hdlist1">\r
155 GET_BAR_CONFIG (6)\r
156 </dt>\r
157 <dd>\r
158 <p>\r
159         Gets the configuration (as JSON map) of the workspace bar with the\r
160         given ID. If no ID is provided, an array with all configured bar IDs is\r
161         returned instead.\r
162 </p>\r
163 </dd>\r
164 <dt class="hdlist1">\r
165 GET_VERSION (7)\r
166 </dt>\r
167 <dd>\r
168 <p>\r
169         Gets the version of i3. The reply will be a JSON-encoded dictionary\r
170         with the major, minor, patch and human-readable version.\r
171 </p>\r
172 </dd>\r
173 <dt class="hdlist1">\r
174 GET_BINDING_MODES (8)\r
175 </dt>\r
176 <dd>\r
177 <p>\r
178         Gets a list of currently configured binding modes.\r
179 </p>\r
180 </dd>\r
181 </dl></div>\r
182 <div class="paragraph"><p>So, a typical message could look like this:</p></div>\r
183 <div class="listingblock">\r
184 <div class="content">\r
185 <pre><tt>"i3-ipc" &lt;message length&gt; &lt;message type&gt; &lt;payload&gt;</tt></pre>\r
186 </div></div>\r
187 <div class="paragraph"><p>Or, as a hexdump:</p></div>\r
188 <div class="listingblock">\r
189 <div class="content">\r
190 <pre><tt>00000000  69 33 2d 69 70 63 04 00  00 00 00 00 00 00 65 78  |i3-ipc........ex|\r
191 00000010  69 74                                             |it|</tt></pre>\r
192 </div></div>\r
193 <div class="paragraph"><p>To generate and send such a message, you could use the following code in Perl:</p></div>\r
194 <div class="listingblock">\r
195 <div class="content">\r
196 <pre><tt>sub format_ipc_command {\r
197     my ($msg) = @_;\r
198     my $len;\r
199     # Get the real byte count (vs. amount of characters)\r
200     { use bytes; $len = length($msg); }\r
201     return "i3-ipc" . pack("LL", $len, 0) . $msg;\r
202 }\r
203 \r
204 $sock-&gt;write(format_ipc_command("exit"));</tt></pre>\r
205 </div></div>\r
206 </div>\r
207 </div>\r
208 <div class="sect1">\r
209 <h2 id="_receiving_replies_from_i3">3. Receiving replies from i3</h2>\r
210 <div class="sectionbody">\r
211 <div class="paragraph"><p>Replies from i3 usually consist of a simple string (the length of the string\r
212 is the message_length, so you can consider them length-prefixed) which in turn\r
213 contain the JSON serialization of a data structure. For example, the\r
214 GET_WORKSPACES message returns an array of workspaces (each workspace is a map\r
215 with certain attributes).</p></div>\r
216 <div class="sect2">\r
217 <h3 id="_reply_format">3.1. Reply format</h3>\r
218 <div class="paragraph"><p>The reply format is identical to the normal message format. There also is\r
219 the magic string, then the message length, then the message type and the\r
220 payload.</p></div>\r
221 <div class="paragraph"><p>The following reply types are implemented:</p></div>\r
222 <div class="dlist"><dl>\r
223 <dt class="hdlist1">\r
224 COMMAND (0)\r
225 </dt>\r
226 <dd>\r
227 <p>\r
228         Confirmation/Error code for the COMMAND message.\r
229 </p>\r
230 </dd>\r
231 <dt class="hdlist1">\r
232 WORKSPACES (1)\r
233 </dt>\r
234 <dd>\r
235 <p>\r
236         Reply to the GET_WORKSPACES message.\r
237 </p>\r
238 </dd>\r
239 <dt class="hdlist1">\r
240 SUBSCRIBE (2)\r
241 </dt>\r
242 <dd>\r
243 <p>\r
244         Confirmation/Error code for the SUBSCRIBE message.\r
245 </p>\r
246 </dd>\r
247 <dt class="hdlist1">\r
248 OUTPUTS (3)\r
249 </dt>\r
250 <dd>\r
251 <p>\r
252         Reply to the GET_OUTPUTS message.\r
253 </p>\r
254 </dd>\r
255 <dt class="hdlist1">\r
256 TREE (4)\r
257 </dt>\r
258 <dd>\r
259 <p>\r
260         Reply to the GET_TREE message.\r
261 </p>\r
262 </dd>\r
263 <dt class="hdlist1">\r
264 MARKS (5)\r
265 </dt>\r
266 <dd>\r
267 <p>\r
268         Reply to the GET_MARKS message.\r
269 </p>\r
270 </dd>\r
271 <dt class="hdlist1">\r
272 BAR_CONFIG (6)\r
273 </dt>\r
274 <dd>\r
275 <p>\r
276         Reply to the GET_BAR_CONFIG message.\r
277 </p>\r
278 </dd>\r
279 <dt class="hdlist1">\r
280 VERSION (7)\r
281 </dt>\r
282 <dd>\r
283 <p>\r
284         Reply to the GET_VERSION message.\r
285 </p>\r
286 </dd>\r
287 <dt class="hdlist1">\r
288 BINDING_MODES (8)\r
289 </dt>\r
290 <dd>\r
291 <p>\r
292         Reply to the GET_BINDING_MODES message.\r
293 </p>\r
294 </dd>\r
295 </dl></div>\r
296 </div>\r
297 <div class="sect2">\r
298 <h3 id="_command_reply">3.2. COMMAND reply</h3>\r
299 <div class="paragraph"><p>The reply consists of a list of serialized maps for each command that was\r
300 parsed. Each has the property <tt>success (bool)</tt> and may also include a\r
301 human-readable error message in the property <tt>error (string)</tt>.</p></div>\r
302 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
303 <div class="listingblock">\r
304 <div class="content">\r
305 <pre><tt>[{ "success": true }]</tt></pre>\r
306 </div></div>\r
307 </div>\r
308 <div class="sect2">\r
309 <h3 id="_workspaces_reply">3.3. WORKSPACES reply</h3>\r
310 <div class="paragraph"><p>The reply consists of a serialized list of workspaces. Each workspace has the\r
311 following properties:</p></div>\r
312 <div class="dlist"><dl>\r
313 <dt class="hdlist1">\r
314 num (integer)\r
315 </dt>\r
316 <dd>\r
317 <p>\r
318         The logical number of the workspace. Corresponds to the command\r
319         to switch to this workspace. For named workspaces, this will be -1.\r
320 </p>\r
321 </dd>\r
322 <dt class="hdlist1">\r
323 name (string)\r
324 </dt>\r
325 <dd>\r
326 <p>\r
327         The name of this workspace (by default num+1), as changed by the\r
328         user. Encoded in UTF-8.\r
329 </p>\r
330 </dd>\r
331 <dt class="hdlist1">\r
332 visible (boolean)\r
333 </dt>\r
334 <dd>\r
335 <p>\r
336         Whether this workspace is currently visible on an output (multiple\r
337         workspaces can be visible at the same time).\r
338 </p>\r
339 </dd>\r
340 <dt class="hdlist1">\r
341 focused (boolean)\r
342 </dt>\r
343 <dd>\r
344 <p>\r
345         Whether this workspace currently has the focus (only one workspace\r
346         can have the focus at the same time).\r
347 </p>\r
348 </dd>\r
349 <dt class="hdlist1">\r
350 urgent (boolean)\r
351 </dt>\r
352 <dd>\r
353 <p>\r
354         Whether a window on this workspace has the "urgent" flag set.\r
355 </p>\r
356 </dd>\r
357 <dt class="hdlist1">\r
358 rect (map)\r
359 </dt>\r
360 <dd>\r
361 <p>\r
362         The rectangle of this workspace (equals the rect of the output it\r
363         is on), consists of x, y, width, height.\r
364 </p>\r
365 </dd>\r
366 <dt class="hdlist1">\r
367 output (string)\r
368 </dt>\r
369 <dd>\r
370 <p>\r
371         The video output this workspace is on (LVDS1, VGA1, …).\r
372 </p>\r
373 </dd>\r
374 </dl></div>\r
375 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
376 <div class="listingblock">\r
377 <div class="content">\r
378 <pre><tt>[\r
379  {\r
380   "num": 0,\r
381   "name": "1",\r
382   "visible": true,\r
383   "focused": true,\r
384   "urgent": false,\r
385   "rect": {\r
386    "x": 0,\r
387    "y": 0,\r
388    "width": 1280,\r
389    "height": 800\r
390   },\r
391   "output": "LVDS1"\r
392  },\r
393  {\r
394   "num": 1,\r
395   "name": "2",\r
396   "visible": false,\r
397   "focused": false,\r
398   "urgent": false,\r
399   "rect": {\r
400    "x": 0,\r
401    "y": 0,\r
402    "width": 1280,\r
403    "height": 800\r
404   },\r
405   "output": "LVDS1"\r
406  }\r
407 ]</tt></pre>\r
408 </div></div>\r
409 </div>\r
410 <div class="sect2">\r
411 <h3 id="_subscribe_reply">3.4. SUBSCRIBE reply</h3>\r
412 <div class="paragraph"><p>The reply consists of a single serialized map. The only property is\r
413 <tt>success (bool)</tt>, indicating whether the subscription was successful (the\r
414 default) or whether a JSON parse error occurred.</p></div>\r
415 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
416 <div class="listingblock">\r
417 <div class="content">\r
418 <pre><tt>{ "success": true }</tt></pre>\r
419 </div></div>\r
420 </div>\r
421 <div class="sect2">\r
422 <h3 id="_outputs_reply">3.5. OUTPUTS reply</h3>\r
423 <div class="paragraph"><p>The reply consists of a serialized list of outputs. Each output has the\r
424 following properties:</p></div>\r
425 <div class="dlist"><dl>\r
426 <dt class="hdlist1">\r
427 name (string)\r
428 </dt>\r
429 <dd>\r
430 <p>\r
431         The name of this output (as seen in <tt>xrandr(1)</tt>). Encoded in UTF-8.\r
432 </p>\r
433 </dd>\r
434 <dt class="hdlist1">\r
435 active (boolean)\r
436 </dt>\r
437 <dd>\r
438 <p>\r
439         Whether this output is currently active (has a valid mode).\r
440 </p>\r
441 </dd>\r
442 <dt class="hdlist1">\r
443 primary (boolean)\r
444 </dt>\r
445 <dd>\r
446 <p>\r
447         Whether this output is currently the primary output.\r
448 </p>\r
449 </dd>\r
450 <dt class="hdlist1">\r
451 current_workspace (string)\r
452 </dt>\r
453 <dd>\r
454 <p>\r
455         The name of the current workspace that is visible on this output. <tt>null</tt> if\r
456         the output is not active.\r
457 </p>\r
458 </dd>\r
459 <dt class="hdlist1">\r
460 rect (map)\r
461 </dt>\r
462 <dd>\r
463 <p>\r
464         The rectangle of this output (equals the rect of the output it\r
465         is on), consists of x, y, width, height.\r
466 </p>\r
467 </dd>\r
468 </dl></div>\r
469 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
470 <div class="listingblock">\r
471 <div class="content">\r
472 <pre><tt>[\r
473  {\r
474   "name": "LVDS1",\r
475   "active": true,\r
476   "current_workspace": "4",\r
477   "rect": {\r
478    "x": 0,\r
479    "y": 0,\r
480    "width": 1280,\r
481    "height": 800\r
482   }\r
483  },\r
484  {\r
485   "name": "VGA1",\r
486   "active": true,\r
487   "current_workspace": "1",\r
488   "rect": {\r
489    "x": 1280,\r
490    "y": 0,\r
491    "width": 1280,\r
492    "height": 1024\r
493   }\r
494  }\r
495 ]</tt></pre>\r
496 </div></div>\r
497 </div>\r
498 <div class="sect2">\r
499 <h3 id="_tree_reply">3.6. TREE reply</h3>\r
500 <div class="paragraph"><p>The reply consists of a serialized tree. Each node in the tree (representing\r
501 one container) has at least the properties listed below. While the nodes might\r
502 have more properties, please do not use any properties which are not documented\r
503 here. They are not yet finalized and will probably change!</p></div>\r
504 <div class="dlist"><dl>\r
505 <dt class="hdlist1">\r
506 id (integer)\r
507 </dt>\r
508 <dd>\r
509 <p>\r
510         The internal ID (actually a C pointer value) of this container. Do not\r
511         make any assumptions about it. You can use it to (re-)identify and\r
512         address containers when talking to i3.\r
513 </p>\r
514 </dd>\r
515 <dt class="hdlist1">\r
516 name (string)\r
517 </dt>\r
518 <dd>\r
519 <p>\r
520         The internal name of this container. For all containers which are part\r
521         of the tree structure down to the workspace contents, this is set to a\r
522         nice human-readable name of the container.\r
523         For containers that have an X11 window, the content is the title\r
524         (_NET_WM_NAME property) of that window.\r
525         For all other containers, the content is not defined (yet).\r
526 </p>\r
527 </dd>\r
528 <dt class="hdlist1">\r
529 type (string)\r
530 </dt>\r
531 <dd>\r
532 <p>\r
533         Type of this container. Can be one of "root", "output", "con",\r
534         "floating_con", "workspace" or "dockarea".\r
535 </p>\r
536 </dd>\r
537 <dt class="hdlist1">\r
538 border (string)\r
539 </dt>\r
540 <dd>\r
541 <p>\r
542         Can be either "normal", "none" or "pixel", depending on the\r
543         container’s border style.\r
544 </p>\r
545 </dd>\r
546 <dt class="hdlist1">\r
547 current_border_width (integer)\r
548 </dt>\r
549 <dd>\r
550 <p>\r
551         Number of pixels of the border width.\r
552 </p>\r
553 </dd>\r
554 <dt class="hdlist1">\r
555 layout (string)\r
556 </dt>\r
557 <dd>\r
558 <p>\r
559         Can be either "splith", "splitv", "stacked", "tabbed", "dockarea" or\r
560         "output".\r
561         Other values might be possible in the future, should we add new\r
562         layouts.\r
563 </p>\r
564 </dd>\r
565 <dt class="hdlist1">\r
566 orientation (string)\r
567 </dt>\r
568 <dd>\r
569 <p>\r
570         Can be either "none" (for non-split containers), "horizontal" or\r
571         "vertical".\r
572         THIS FIELD IS OBSOLETE. It is still present, but your code should not\r
573         use it. Instead, rely on the layout field.\r
574 </p>\r
575 </dd>\r
576 <dt class="hdlist1">\r
577 percent (float)\r
578 </dt>\r
579 <dd>\r
580 <p>\r
581         The percentage which this container takes in its parent. A value of\r
582         <tt>null</tt> means that the percent property does not make sense for this\r
583         container, for example for the root container.\r
584 </p>\r
585 </dd>\r
586 <dt class="hdlist1">\r
587 rect (map)\r
588 </dt>\r
589 <dd>\r
590 <p>\r
591         The absolute display coordinates for this container. Display\r
592         coordinates means that when you have two 1600x1200 monitors on a single\r
593         X11 Display (the standard way), the coordinates of the first window on\r
594         the second monitor are <tt>{ "x": 1600, "y": 0, "width": 1600, "height":\r
595         1200 }</tt>.\r
596 </p>\r
597 </dd>\r
598 <dt class="hdlist1">\r
599 window_rect (map)\r
600 </dt>\r
601 <dd>\r
602 <p>\r
603         The coordinates of the <strong>actual client window</strong> inside its container.\r
604         These coordinates are relative to the container and do not include the\r
605         window decoration (which is actually rendered on the parent container).\r
606         So, when using the <tt>default</tt> layout, you will have a 2 pixel border on\r
607         each side, making the window_rect <tt>{ "x": 2, "y": 0, "width": 632,\r
608         "height": 366 }</tt> (for example).\r
609 </p>\r
610 </dd>\r
611 <dt class="hdlist1">\r
612 deco_rect (map)\r
613 </dt>\r
614 <dd>\r
615 <p>\r
616         The coordinates of the <strong>window decoration</strong> inside its container. These\r
617         coordinates are relative to the container and do not include the actual\r
618         client window.\r
619 </p>\r
620 </dd>\r
621 <dt class="hdlist1">\r
622 geometry (map)\r
623 </dt>\r
624 <dd>\r
625 <p>\r
626         The original geometry the window specified when i3 mapped it. Used when\r
627         switching a window to floating mode, for example.\r
628 </p>\r
629 </dd>\r
630 <dt class="hdlist1">\r
631 window (integer)\r
632 </dt>\r
633 <dd>\r
634 <p>\r
635         The X11 window ID of the <strong>actual client window</strong> inside this container.\r
636         This field is set to null for split containers or otherwise empty\r
637         containers. This ID corresponds to what xwininfo(1) and other\r
638         X11-related tools display (usually in hex).\r
639 </p>\r
640 </dd>\r
641 <dt class="hdlist1">\r
642 urgent (bool)\r
643 </dt>\r
644 <dd>\r
645 <p>\r
646         Whether this container (window or workspace) has the urgency hint set.\r
647 </p>\r
648 </dd>\r
649 <dt class="hdlist1">\r
650 focused (bool)\r
651 </dt>\r
652 <dd>\r
653 <p>\r
654         Whether this container is currently focused.\r
655 </p>\r
656 </dd>\r
657 </dl></div>\r
658 <div class="paragraph"><p>Please note that in the following example, I have left out some keys/values\r
659 which are not relevant for the type of the node. Otherwise, the example would\r
660 be by far too long (it already is quite long, despite showing only 1 window and\r
661 one dock window).</p></div>\r
662 <div class="paragraph"><p>It is useful to have an overview of the structure before taking a look at the\r
663 JSON dump:</p></div>\r
664 <div class="ulist"><ul>\r
665 <li>\r
666 <p>\r
667 root\r
668 </p>\r
669 <div class="ulist"><ul>\r
670 <li>\r
671 <p>\r
672 LVDS1\r
673 </p>\r
674 <div class="ulist"><ul>\r
675 <li>\r
676 <p>\r
677 topdock\r
678 </p>\r
679 </li>\r
680 <li>\r
681 <p>\r
682 content\r
683 </p>\r
684 <div class="ulist"><ul>\r
685 <li>\r
686 <p>\r
687 workspace 1\r
688 </p>\r
689 <div class="ulist"><ul>\r
690 <li>\r
691 <p>\r
692 window 1\r
693 </p>\r
694 </li>\r
695 </ul></div>\r
696 </li>\r
697 </ul></div>\r
698 </li>\r
699 <li>\r
700 <p>\r
701 bottomdock\r
702 </p>\r
703 <div class="ulist"><ul>\r
704 <li>\r
705 <p>\r
706 dock window 1\r
707 </p>\r
708 </li>\r
709 </ul></div>\r
710 </li>\r
711 </ul></div>\r
712 </li>\r
713 <li>\r
714 <p>\r
715 VGA1\r
716 </p>\r
717 </li>\r
718 </ul></div>\r
719 </li>\r
720 </ul></div>\r
721 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
722 <div class="listingblock">\r
723 <div class="content">\r
724 <pre><tt>{\r
725  "id": 6875648,\r
726  "name": "root",\r
727  "rect": {\r
728    "x": 0,\r
729    "y": 0,\r
730    "width": 1280,\r
731    "height": 800\r
732  },\r
733  "nodes": [\r
734 \r
735    {\r
736     "id": 6878320,\r
737     "name": "LVDS1",\r
738     "layout": "output",\r
739     "rect": {\r
740       "x": 0,\r
741       "y": 0,\r
742       "width": 1280,\r
743       "height": 800\r
744     },\r
745     "nodes": [\r
746 \r
747       {\r
748        "id": 6878784,\r
749        "name": "topdock",\r
750        "layout": "dockarea",\r
751        "orientation": "vertical",\r
752        "rect": {\r
753          "x": 0,\r
754          "y": 0,\r
755          "width": 1280,\r
756          "height": 0\r
757        }\r
758       },\r
759 \r
760       {\r
761        "id": 6879344,\r
762        "name": "content",\r
763        "rect": {\r
764          "x": 0,\r
765          "y": 0,\r
766          "width": 1280,\r
767          "height": 782\r
768        },\r
769        "nodes": [\r
770 \r
771          {\r
772           "id": 6880464,\r
773           "name": "1",\r
774           "orientation": "horizontal",\r
775           "rect": {\r
776             "x": 0,\r
777             "y": 0,\r
778             "width": 1280,\r
779             "height": 782\r
780           },\r
781           "floating_nodes": [],\r
782           "nodes": [\r
783 \r
784             {\r
785              "id": 6929968,\r
786              "name": "#aa0000",\r
787              "border": "normal",\r
788              "percent": 1,\r
789              "rect": {\r
790                "x": 0,\r
791                "y": 18,\r
792                "width": 1280,\r
793                "height": 782\r
794              }\r
795             }\r
796 \r
797           ]\r
798          }\r
799 \r
800        ]\r
801       },\r
802 \r
803       {\r
804        "id": 6880208,\r
805        "name": "bottomdock",\r
806        "layout": "dockarea",\r
807        "orientation": "vertical",\r
808        "rect": {\r
809          "x": 0,\r
810          "y": 782,\r
811          "width": 1280,\r
812          "height": 18\r
813        },\r
814        "nodes": [\r
815 \r
816          {\r
817           "id": 6931312,\r
818           "name": "#00aa00",\r
819           "percent": 1,\r
820           "rect": {\r
821             "x": 0,\r
822             "y": 782,\r
823             "width": 1280,\r
824             "height": 18\r
825           }\r
826          }\r
827 \r
828        ]\r
829       }\r
830     ]\r
831    }\r
832  ]\r
833 }</tt></pre>\r
834 </div></div>\r
835 </div>\r
836 <div class="sect2">\r
837 <h3 id="_marks_reply">3.7. MARKS reply</h3>\r
838 <div class="paragraph"><p>The reply consists of a single array of strings for each container that has a\r
839 mark. A mark can only be set on one container, so the array is unique.\r
840 The order of that array is undefined.</p></div>\r
841 <div class="paragraph"><p>If no window has a mark the response will be the empty array [].</p></div>\r
842 </div>\r
843 <div class="sect2">\r
844 <h3 id="_bar_config_reply">3.8. BAR_CONFIG reply</h3>\r
845 <div class="paragraph"><p>This can be used by third-party workspace bars (especially i3bar, but others\r
846 are free to implement compatible alternatives) to get the <tt>bar</tt> block\r
847 configuration from i3.</p></div>\r
848 <div class="paragraph"><p>Depending on the input, the reply is either:</p></div>\r
849 <div class="dlist"><dl>\r
850 <dt class="hdlist1">\r
851 empty input\r
852 </dt>\r
853 <dd>\r
854 <p>\r
855         An array of configured bar IDs\r
856 </p>\r
857 </dd>\r
858 <dt class="hdlist1">\r
859 Bar ID\r
860 </dt>\r
861 <dd>\r
862 <p>\r
863         A JSON map containing the configuration for the specified bar.\r
864 </p>\r
865 </dd>\r
866 </dl></div>\r
867 <div class="paragraph"><p>Each bar configuration has the following properties:</p></div>\r
868 <div class="dlist"><dl>\r
869 <dt class="hdlist1">\r
870 id (string)\r
871 </dt>\r
872 <dd>\r
873 <p>\r
874         The ID for this bar. Included in case you request multiple\r
875         configurations and want to differentiate the different replies.\r
876 </p>\r
877 </dd>\r
878 <dt class="hdlist1">\r
879 mode (string)\r
880 </dt>\r
881 <dd>\r
882 <p>\r
883         Either <tt>dock</tt> (the bar sets the dock window type) or <tt>hide</tt> (the bar\r
884         does not show unless a specific key is pressed).\r
885 </p>\r
886 </dd>\r
887 <dt class="hdlist1">\r
888 position (string)\r
889 </dt>\r
890 <dd>\r
891 <p>\r
892         Either <tt>bottom</tt> or <tt>top</tt> at the moment.\r
893 </p>\r
894 </dd>\r
895 <dt class="hdlist1">\r
896 status_command (string)\r
897 </dt>\r
898 <dd>\r
899 <p>\r
900         Command which will be run to generate a statusline. Each line on stdout\r
901         of this command will be displayed in the bar. At the moment, no\r
902         formatting is supported.\r
903 </p>\r
904 </dd>\r
905 <dt class="hdlist1">\r
906 font (string)\r
907 </dt>\r
908 <dd>\r
909 <p>\r
910         The font to use for text on the bar.\r
911 </p>\r
912 </dd>\r
913 <dt class="hdlist1">\r
914 workspace_buttons (boolean)\r
915 </dt>\r
916 <dd>\r
917 <p>\r
918         Display workspace buttons or not? Defaults to true.\r
919 </p>\r
920 </dd>\r
921 <dt class="hdlist1">\r
922 binding_mode_indicator (boolean)\r
923 </dt>\r
924 <dd>\r
925 <p>\r
926         Display the mode indicator or not? Defaults to true.\r
927 </p>\r
928 </dd>\r
929 <dt class="hdlist1">\r
930 verbose (boolean)\r
931 </dt>\r
932 <dd>\r
933 <p>\r
934         Should the bar enable verbose output for debugging? Defaults to false.\r
935 </p>\r
936 </dd>\r
937 <dt class="hdlist1">\r
938 colors (map)\r
939 </dt>\r
940 <dd>\r
941 <p>\r
942         Contains key/value pairs of colors. Each value is a color code in hex,\r
943         formatted #rrggbb (like in HTML).\r
944 </p>\r
945 </dd>\r
946 </dl></div>\r
947 <div class="paragraph"><p>The following colors can be configured at the moment:</p></div>\r
948 <div class="dlist"><dl>\r
949 <dt class="hdlist1">\r
950 background\r
951 </dt>\r
952 <dd>\r
953 <p>\r
954         Background color of the bar.\r
955 </p>\r
956 </dd>\r
957 <dt class="hdlist1">\r
958 statusline\r
959 </dt>\r
960 <dd>\r
961 <p>\r
962         Text color to be used for the statusline.\r
963 </p>\r
964 </dd>\r
965 <dt class="hdlist1">\r
966 separator\r
967 </dt>\r
968 <dd>\r
969 <p>\r
970         Text color to be used for the separator.\r
971 </p>\r
972 </dd>\r
973 <dt class="hdlist1">\r
974 focused_background\r
975 </dt>\r
976 <dd>\r
977 <p>\r
978         Background color of the bar on the currently focused monitor output.\r
979 </p>\r
980 </dd>\r
981 <dt class="hdlist1">\r
982 focused_statusline\r
983 </dt>\r
984 <dd>\r
985 <p>\r
986         Text color to be used for the statusline on the currently focused\r
987         monitor output.\r
988 </p>\r
989 </dd>\r
990 <dt class="hdlist1">\r
991 focused_separator\r
992 </dt>\r
993 <dd>\r
994 <p>\r
995         Text color to be used for the separator on the currently focused\r
996         monitor output.\r
997 </p>\r
998 </dd>\r
999 <dt class="hdlist1">\r
1000 focused_workspace_text/focused_workspace_bg/focused_workspace_border\r
1001 </dt>\r
1002 <dd>\r
1003 <p>\r
1004         Text/background/border color for a workspace button when the workspace\r
1005         has focus.\r
1006 </p>\r
1007 </dd>\r
1008 <dt class="hdlist1">\r
1009 active_workspace_text/active_workspace_bg/active_workspace_border\r
1010 </dt>\r
1011 <dd>\r
1012 <p>\r
1013         Text/background/border color for a workspace button when the workspace\r
1014         is active (visible) on some output, but the focus is on another one.\r
1015         You can only tell this apart from the focused workspace when you are\r
1016         using multiple monitors.\r
1017 </p>\r
1018 </dd>\r
1019 <dt class="hdlist1">\r
1020 inactive_workspace_text/inactive_workspace_bg/inactive_workspace_border\r
1021 </dt>\r
1022 <dd>\r
1023 <p>\r
1024         Text/background/border color for a workspace button when the workspace\r
1025         does not have focus and is not active (visible) on any output. This\r
1026         will be the case for most workspaces.\r
1027 </p>\r
1028 </dd>\r
1029 <dt class="hdlist1">\r
1030 urgent_workspace_text/urgent_workspace_bg/urgent_workspace_border\r
1031 </dt>\r
1032 <dd>\r
1033 <p>\r
1034         Text/background/border color for workspaces which contain at least one\r
1035         window with the urgency hint set.\r
1036 </p>\r
1037 </dd>\r
1038 <dt class="hdlist1">\r
1039 binding_mode_text/binding_mode_bg/binding_mode_border\r
1040 </dt>\r
1041 <dd>\r
1042 <p>\r
1043         Text/background/border color for the binding mode indicator.\r
1044 </p>\r
1045 </dd>\r
1046 </dl></div>\r
1047 <div class="paragraph"><p><strong>Example of configured bars:</strong></p></div>\r
1048 <div class="listingblock">\r
1049 <div class="content">\r
1050 <pre><tt>["bar-bxuqzf"]</tt></pre>\r
1051 </div></div>\r
1052 <div class="paragraph"><p><strong>Example of bar configuration:</strong></p></div>\r
1053 <div class="listingblock">\r
1054 <div class="content">\r
1055 <pre><tt>{\r
1056  "id": "bar-bxuqzf",\r
1057  "mode": "dock",\r
1058  "position": "bottom",\r
1059  "status_command": "i3status",\r
1060  "font": "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1",\r
1061  "workspace_buttons": true,\r
1062  "binding_mode_indicator": true,\r
1063  "verbose": false,\r
1064  "colors": {\r
1065    "background": "#c0c0c0",\r
1066    "statusline": "#00ff00",\r
1067    "focused_workspace_text": "#ffffff",\r
1068    "focused_workspace_bg": "#000000"\r
1069  }\r
1070 }</tt></pre>\r
1071 </div></div>\r
1072 </div>\r
1073 <div class="sect2">\r
1074 <h3 id="_version_reply">3.9. VERSION reply</h3>\r
1075 <div class="paragraph"><p>The reply consists of a single JSON dictionary with the following keys:</p></div>\r
1076 <div class="dlist"><dl>\r
1077 <dt class="hdlist1">\r
1078 major (integer)\r
1079 </dt>\r
1080 <dd>\r
1081 <p>\r
1082         The major version of i3, such as <tt>4</tt>.\r
1083 </p>\r
1084 </dd>\r
1085 <dt class="hdlist1">\r
1086 minor (integer)\r
1087 </dt>\r
1088 <dd>\r
1089 <p>\r
1090         The minor version of i3, such as <tt>2</tt>. Changes in the IPC interface (new\r
1091         features) will only occur with new minor (or major) releases. However,\r
1092         bugfixes might be introduced in patch releases, too.\r
1093 </p>\r
1094 </dd>\r
1095 <dt class="hdlist1">\r
1096 patch (integer)\r
1097 </dt>\r
1098 <dd>\r
1099 <p>\r
1100         The patch version of i3, such as <tt>1</tt> (when the complete version is\r
1101         <tt>4.2.1</tt>). For versions such as <tt>4.2</tt>, patch will be set to <tt>0</tt>.\r
1102 </p>\r
1103 </dd>\r
1104 <dt class="hdlist1">\r
1105 human_readable (string)\r
1106 </dt>\r
1107 <dd>\r
1108 <p>\r
1109         A human-readable version of i3 containing the precise git version,\r
1110         build date and branch name. When you need to display the i3 version to\r
1111         your users, use the human-readable version whenever possible (since\r
1112         this is what <tt>i3 --version</tt> displays, too).\r
1113 </p>\r
1114 </dd>\r
1115 <dt class="hdlist1">\r
1116 loaded_config_file_name (string)\r
1117 </dt>\r
1118 <dd>\r
1119 <p>\r
1120         The current config path.\r
1121 </p>\r
1122 </dd>\r
1123 </dl></div>\r
1124 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1125 <div class="listingblock">\r
1126 <div class="content">\r
1127 <pre><tt>{\r
1128    "human_readable" : "4.2-169-gf80b877 (2012-08-05, branch \"next\")",\r
1129    "loaded_config_file_name" : "/home/hwangcc23/.i3/config",\r
1130    "minor" : 2,\r
1131    "patch" : 0,\r
1132    "major" : 4\r
1133 }</tt></pre>\r
1134 </div></div>\r
1135 </div>\r
1136 <div class="sect2">\r
1137 <h3 id="_binding_modes_reply">3.10. BINDING_MODES reply</h3>\r
1138 <div class="paragraph"><p>The reply consists of an array of all currently configured binding modes.</p></div>\r
1139 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1140 <div class="listingblock">\r
1141 <div class="content">\r
1142 <pre><tt>["default", "resize"]</tt></pre>\r
1143 </div></div>\r
1144 </div>\r
1145 </div>\r
1146 </div>\r
1147 <div class="sect1">\r
1148 <h2 id="_events">4. Events</h2>\r
1149 <div class="sectionbody">\r
1150 <div class="paragraph" id="events"><p>To get informed when certain things happen in i3, clients can subscribe to\r
1151 events. Events consist of a name (like "workspace") and an event reply type\r
1152 (like I3_IPC_EVENT_WORKSPACE). The events sent by i3 are in the same format\r
1153 as replies to specific commands. However, the highest bit of the message type\r
1154 is set to 1 to indicate that this is an event reply instead of a normal reply.</p></div>\r
1155 <div class="paragraph"><p>Caveat: As soon as you subscribe to an event, it is not guaranteed any longer\r
1156 that the requests to i3 are processed in order. This means, the following\r
1157 situation can happen: You send a GET_WORKSPACES request but you receive a\r
1158 "workspace" event before receiving the reply to GET_WORKSPACES. If your\r
1159 program does not want to cope which such kinds of race conditions (an\r
1160 event based library may not have a problem here), I suggest you create a\r
1161 separate connection to receive events.</p></div>\r
1162 <div class="sect2">\r
1163 <h3 id="_subscribing_to_events">4.1. Subscribing to events</h3>\r
1164 <div class="paragraph"><p>By sending a message of type SUBSCRIBE with a JSON-encoded array as payload\r
1165 you can register to an event.</p></div>\r
1166 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1167 <div class="listingblock">\r
1168 <div class="content">\r
1169 <pre><tt>type: SUBSCRIBE\r
1170 payload: [ "workspace", "output" ]</tt></pre>\r
1171 </div></div>\r
1172 </div>\r
1173 <div class="sect2">\r
1174 <h3 id="_available_events">4.2. Available events</h3>\r
1175 <div class="paragraph"><p>The numbers in parenthesis is the event type (keep in mind that you need to\r
1176 strip the highest bit first).</p></div>\r
1177 <div class="dlist"><dl>\r
1178 <dt class="hdlist1">\r
1179 workspace (0)\r
1180 </dt>\r
1181 <dd>\r
1182 <p>\r
1183         Sent when the user switches to a different workspace, when a new\r
1184         workspace is initialized or when a workspace is removed (because the\r
1185         last client vanished).\r
1186 </p>\r
1187 </dd>\r
1188 <dt class="hdlist1">\r
1189 output (1)\r
1190 </dt>\r
1191 <dd>\r
1192 <p>\r
1193         Sent when RandR issues a change notification (of either screens,\r
1194         outputs, CRTCs or output properties).\r
1195 </p>\r
1196 </dd>\r
1197 <dt class="hdlist1">\r
1198 mode (2)\r
1199 </dt>\r
1200 <dd>\r
1201 <p>\r
1202         Sent whenever i3 changes its binding mode.\r
1203 </p>\r
1204 </dd>\r
1205 <dt class="hdlist1">\r
1206 window (3)\r
1207 </dt>\r
1208 <dd>\r
1209 <p>\r
1210         Sent when a client&#8217;s window is successfully reparented (that is when i3\r
1211         has finished fitting it into a container), when a window received input\r
1212         focus or when certain properties of the window have changed.\r
1213 </p>\r
1214 </dd>\r
1215 <dt class="hdlist1">\r
1216 barconfig_update (4)\r
1217 </dt>\r
1218 <dd>\r
1219 <p>\r
1220     Sent when the hidden_state or mode field in the barconfig of any bar\r
1221     instance was updated and when the config is reloaded.\r
1222 </p>\r
1223 </dd>\r
1224 <dt class="hdlist1">\r
1225 binding (5)\r
1226 </dt>\r
1227 <dd>\r
1228 <p>\r
1229         Sent when a configured command binding is triggered with the keyboard or\r
1230         mouse\r
1231 </p>\r
1232 </dd>\r
1233 <dt class="hdlist1">\r
1234 shutdown (6)\r
1235 </dt>\r
1236 <dd>\r
1237 <p>\r
1238         Sent when the ipc shuts down because of a restart or exit by user command\r
1239 </p>\r
1240 </dd>\r
1241 </dl></div>\r
1242 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1243 <div class="listingblock">\r
1244 <div class="content">\r
1245 <pre><tt># the appropriate 4 bytes read from the socket are stored in $input\r
1246 \r
1247 # unpack a 32-bit unsigned integer\r
1248 my $message_type = unpack("L", $input);\r
1249 \r
1250 # check if the highest bit is 1\r
1251 my $is_event = (($message_type &gt;&gt; 31) == 1);\r
1252 \r
1253 # use the other bits\r
1254 my $event_type = ($message_type &amp; 0x7F);\r
1255 \r
1256 if ($is_event) {\r
1257   say "Received event of type $event_type";\r
1258 }</tt></pre>\r
1259 </div></div>\r
1260 </div>\r
1261 <div class="sect2">\r
1262 <h3 id="_workspace_event">4.3. workspace event</h3>\r
1263 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1264 <tt>change (string)</tt> which indicates the type of the change ("focus", "init",\r
1265 "empty", "urgent", "reload", "rename", "restored", "move"). A\r
1266 <tt>current (object)</tt> property will be present with the affected workspace\r
1267 whenever the type of event affects a workspace (otherwise, it will be +null).</p></div>\r
1268 <div class="paragraph"><p>When the change is "focus", an <tt>old (object)</tt> property will be present with the\r
1269 previous workspace.  When the first switch occurs (when i3 focuses the\r
1270 workspace visible at the beginning) there is no previous workspace, and the\r
1271 <tt>old</tt> property will be set to <tt>null</tt>.  Also note that if the previous is empty\r
1272 it will get destroyed when switching, but will still be present in the "old"\r
1273 property.</p></div>\r
1274 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1275 <div class="listingblock">\r
1276 <div class="content">\r
1277 <pre><tt>{\r
1278  "change": "focus",\r
1279  "current": {\r
1280   "id": 28489712,\r
1281   "type": "workspace",\r
1282   ...\r
1283  }\r
1284  "old": {\r
1285   "id": 28489715,\r
1286   "type": "workspace",\r
1287   ...\r
1288  }\r
1289 }</tt></pre>\r
1290 </div></div>\r
1291 </div>\r
1292 <div class="sect2">\r
1293 <h3 id="_output_event">4.4. output event</h3>\r
1294 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1295 <tt>change (string)</tt> which indicates the type of the change (currently only\r
1296 "unspecified").</p></div>\r
1297 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1298 <div class="listingblock">\r
1299 <div class="content">\r
1300 <pre><tt>{ "change": "unspecified" }</tt></pre>\r
1301 </div></div>\r
1302 </div>\r
1303 <div class="sect2">\r
1304 <h3 id="_mode_event">4.5. mode event</h3>\r
1305 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1306 <tt>change (string)</tt> which holds the name of current mode in use. The name\r
1307 is the same as specified in config when creating a mode. The default\r
1308 mode is simply named default. It contains a second property, <tt>pango_markup</tt>, which\r
1309 defines whether pango markup shall be used for displaying this mode.</p></div>\r
1310 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1311 <div class="listingblock">\r
1312 <div class="content">\r
1313 <pre><tt>{\r
1314   "change": "default",\r
1315   "pango_markup": true\r
1316 }</tt></pre>\r
1317 </div></div>\r
1318 </div>\r
1319 <div class="sect2">\r
1320 <h3 id="_window_event">4.6. window event</h3>\r
1321 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1322 <tt>change (string)</tt> which indicates the type of the change</p></div>\r
1323 <div class="ulist"><ul>\r
1324 <li>\r
1325 <p>\r
1326 <tt>new</tt> – the window has become managed by i3\r
1327 </p>\r
1328 </li>\r
1329 <li>\r
1330 <p>\r
1331 <tt>close</tt> – the window has closed\r
1332 </p>\r
1333 </li>\r
1334 <li>\r
1335 <p>\r
1336 <tt>focus</tt> – the window has received input focus\r
1337 </p>\r
1338 </li>\r
1339 <li>\r
1340 <p>\r
1341 <tt>title</tt> – the window&#8217;s title has changed\r
1342 </p>\r
1343 </li>\r
1344 <li>\r
1345 <p>\r
1346 <tt>fullscreen_mode</tt> – the window has entered or exited fullscreen mode\r
1347 </p>\r
1348 </li>\r
1349 <li>\r
1350 <p>\r
1351 <tt>move</tt> – the window has changed its position in the tree\r
1352 </p>\r
1353 </li>\r
1354 <li>\r
1355 <p>\r
1356 <tt>floating</tt> – the window has transitioned to or from floating\r
1357 </p>\r
1358 </li>\r
1359 <li>\r
1360 <p>\r
1361 <tt>urgent</tt> – the window has become urgent or lost its urgent status\r
1362 </p>\r
1363 </li>\r
1364 <li>\r
1365 <p>\r
1366 <tt>mark</tt> – a mark has been added to or removed from the window\r
1367 </p>\r
1368 </li>\r
1369 </ul></div>\r
1370 <div class="paragraph"><p>Additionally a <tt>container (object)</tt> field will be present, which consists\r
1371 of the window&#8217;s parent container. Be aware that for the "new" event, the\r
1372 container will hold the initial name of the newly reparented window (e.g.\r
1373 if you run urxvt with a shell that changes the title, you will still at\r
1374 this point get the window title as "urxvt").</p></div>\r
1375 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1376 <div class="listingblock">\r
1377 <div class="content">\r
1378 <pre><tt>{\r
1379  "change": "new",\r
1380  "container": {\r
1381   "id": 35569536,\r
1382   "type": "con",\r
1383   ...\r
1384  }\r
1385 }</tt></pre>\r
1386 </div></div>\r
1387 </div>\r
1388 <div class="sect2">\r
1389 <h3 id="_barconfig_update_event">4.7. barconfig_update event</h3>\r
1390 <div class="paragraph"><p>This event consists of a single serialized map reporting on options from the\r
1391 barconfig of the specified bar_id that were updated in i3. This event is the\r
1392 same as a <tt>GET_BAR_CONFIG</tt> reply for the bar with the given id.</p></div>\r
1393 </div>\r
1394 <div class="sect2">\r
1395 <h3 id="_binding_event">4.8. binding event</h3>\r
1396 <div class="paragraph"><p>This event consists of a single serialized map reporting on the details of a\r
1397 binding that ran a command because of user input. The <tt>change (string)</tt> field\r
1398 indicates what sort of binding event was triggered (right now it will always be\r
1399 <tt>"run"</tt> but may be expanded in the future).</p></div>\r
1400 <div class="paragraph"><p>The <tt>binding (object)</tt> field contains details about the binding that was run:</p></div>\r
1401 <div class="dlist"><dl>\r
1402 <dt class="hdlist1">\r
1403 command (string)\r
1404 </dt>\r
1405 <dd>\r
1406 <p>\r
1407         The i3 command that is configured to run for this binding.\r
1408 </p>\r
1409 </dd>\r
1410 <dt class="hdlist1">\r
1411 event_state_mask (array of strings)\r
1412 </dt>\r
1413 <dd>\r
1414 <p>\r
1415         The group and modifier keys that were configured with this binding.\r
1416 </p>\r
1417 </dd>\r
1418 <dt class="hdlist1">\r
1419 input_code (integer)\r
1420 </dt>\r
1421 <dd>\r
1422 <p>\r
1423         If the binding was configured with <tt>bindcode</tt>, this will be the key code\r
1424         that was given for the binding. If the binding is a mouse binding, it will be\r
1425         the number of the mouse button that was pressed. Otherwise it will be 0.\r
1426 </p>\r
1427 </dd>\r
1428 <dt class="hdlist1">\r
1429 symbol (string or null)\r
1430 </dt>\r
1431 <dd>\r
1432 <p>\r
1433         If this is a keyboard binding that was configured with <tt>bindsym</tt>, this\r
1434         field will contain the given symbol. Otherwise it will be <tt>null</tt>.\r
1435 </p>\r
1436 </dd>\r
1437 <dt class="hdlist1">\r
1438 input_type (string)\r
1439 </dt>\r
1440 <dd>\r
1441 <p>\r
1442         This will be <tt>"keyboard"</tt> or <tt>"mouse"</tt> depending on whether or not this was\r
1443         a keyboard or a mouse binding.\r
1444 </p>\r
1445 </dd>\r
1446 </dl></div>\r
1447 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1448 <div class="listingblock">\r
1449 <div class="content">\r
1450 <pre><tt>{\r
1451  "change": "run",\r
1452  "binding": {\r
1453   "command": "nop",\r
1454   "event_state_mask": [\r
1455     "shift",\r
1456     "ctrl"\r
1457   ],\r
1458   "input_code": 0,\r
1459   "symbol": "t",\r
1460   "input_type": "keyboard"\r
1461  }\r
1462 }</tt></pre>\r
1463 </div></div>\r
1464 </div>\r
1465 <div class="sect2">\r
1466 <h3 id="_shutdown_event">4.9. shutdown event</h3>\r
1467 <div class="paragraph"><p>This event is triggered when the connection to the ipc is about to shutdown\r
1468 because of a user action such as a <tt>restart</tt> or <tt>exit</tt> command. The <tt>change\r
1469 (string)</tt> field indicates why the ipc is shutting down. It can be either\r
1470 <tt>"restart"</tt> or <tt>"exit"</tt>.</p></div>\r
1471 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1472 <div class="listingblock">\r
1473 <div class="content">\r
1474 <pre><tt>{\r
1475  "change": "restart"\r
1476 }</tt></pre>\r
1477 </div></div>\r
1478 </div>\r
1479 </div>\r
1480 </div>\r
1481 <div class="sect1">\r
1482 <h2 id="_see_also_existing_libraries">5. See also (existing libraries)</h2>\r
1483 <div class="sectionbody">\r
1484 <div class="paragraph" id="libraries"><p>For some languages, libraries are available (so you don’t have to implement\r
1485 all this on your own). This list names some (if you wrote one, please let me\r
1486 know):</p></div>\r
1487 <div class="dlist"><dl>\r
1488 <dt class="hdlist1">\r
1489 C\r
1490 </dt>\r
1491 <dd>\r
1492 <div class="ulist"><ul>\r
1493 <li>\r
1494 <p>\r
1495 i3 includes a headerfile <tt>i3/ipc.h</tt> which provides you all constants.\r
1496 </p>\r
1497 </li>\r
1498 <li>\r
1499 <p>\r
1500 <a href="https://github.com/acrisci/i3ipc-glib">https://github.com/acrisci/i3ipc-glib</a>\r
1501 </p>\r
1502 </li>\r
1503 </ul></div>\r
1504 </dd>\r
1505 <dt class="hdlist1">\r
1506 C++\r
1507 </dt>\r
1508 <dd>\r
1509 <div class="ulist"><ul>\r
1510 <li>\r
1511 <p>\r
1512 <a href="https://github.com/drmgc/i3ipcpp">https://github.com/drmgc/i3ipcpp</a>\r
1513 </p>\r
1514 </li>\r
1515 </ul></div>\r
1516 </dd>\r
1517 <dt class="hdlist1">\r
1518 Go\r
1519 </dt>\r
1520 <dd>\r
1521 <div class="ulist"><ul>\r
1522 <li>\r
1523 <p>\r
1524 <a href="https://github.com/mdirkse/i3ipc-go">https://github.com/mdirkse/i3ipc-go</a>\r
1525 </p>\r
1526 </li>\r
1527 </ul></div>\r
1528 </dd>\r
1529 <dt class="hdlist1">\r
1530 JavaScript\r
1531 </dt>\r
1532 <dd>\r
1533 <div class="ulist"><ul>\r
1534 <li>\r
1535 <p>\r
1536 <a href="https://github.com/acrisci/i3ipc-gjs">https://github.com/acrisci/i3ipc-gjs</a>\r
1537 </p>\r
1538 </li>\r
1539 </ul></div>\r
1540 </dd>\r
1541 <dt class="hdlist1">\r
1542 Lua\r
1543 </dt>\r
1544 <dd>\r
1545 <div class="ulist"><ul>\r
1546 <li>\r
1547 <p>\r
1548 <a href="https://github.com/acrisci/i3ipc-lua">https://github.com/acrisci/i3ipc-lua</a>\r
1549 </p>\r
1550 </li>\r
1551 </ul></div>\r
1552 </dd>\r
1553 <dt class="hdlist1">\r
1554 Perl\r
1555 </dt>\r
1556 <dd>\r
1557 <div class="ulist"><ul>\r
1558 <li>\r
1559 <p>\r
1560 <a href="https://metacpan.org/module/AnyEvent::I3">https://metacpan.org/module/AnyEvent::I3</a>\r
1561 </p>\r
1562 </li>\r
1563 </ul></div>\r
1564 </dd>\r
1565 <dt class="hdlist1">\r
1566 Python\r
1567 </dt>\r
1568 <dd>\r
1569 <div class="ulist"><ul>\r
1570 <li>\r
1571 <p>\r
1572 <a href="https://github.com/acrisci/i3ipc-python">https://github.com/acrisci/i3ipc-python</a>\r
1573 </p>\r
1574 </li>\r
1575 <li>\r
1576 <p>\r
1577 <a href="https://github.com/whitelynx/i3ipc">https://github.com/whitelynx/i3ipc</a> (not maintained)\r
1578 </p>\r
1579 </li>\r
1580 <li>\r
1581 <p>\r
1582 <a href="https://github.com/ziberna/i3-py">https://github.com/ziberna/i3-py</a> (not maintained)\r
1583 </p>\r
1584 </li>\r
1585 </ul></div>\r
1586 </dd>\r
1587 <dt class="hdlist1">\r
1588 Ruby\r
1589 </dt>\r
1590 <dd>\r
1591 <div class="ulist"><ul>\r
1592 <li>\r
1593 <p>\r
1594 <a href="https://github.com/veelenga/i3ipc-ruby">https://github.com/veelenga/i3ipc-ruby</a>\r
1595 </p>\r
1596 </li>\r
1597 <li>\r
1598 <p>\r
1599 <a href="https://github.com/badboy/i3-ipc">https://github.com/badboy/i3-ipc</a> (not maintained)\r
1600 </p>\r
1601 </li>\r
1602 </ul></div>\r
1603 </dd>\r
1604 <dt class="hdlist1">\r
1605 Rust\r
1606 </dt>\r
1607 <dd>\r
1608 <div class="ulist"><ul>\r
1609 <li>\r
1610 <p>\r
1611 <a href="https://github.com/tmerr/i3ipc-rs">https://github.com/tmerr/i3ipc-rs</a>\r
1612 </p>\r
1613 </li>\r
1614 </ul></div>\r
1615 </dd>\r
1616 <dt class="hdlist1">\r
1617 OCaml\r
1618 </dt>\r
1619 <dd>\r
1620 <div class="ulist"><ul>\r
1621 <li>\r
1622 <p>\r
1623 <a href="https://github.com/Armael/ocaml-i3ipc">https://github.com/Armael/ocaml-i3ipc</a>\r
1624 </p>\r
1625 </li>\r
1626 </ul></div>\r
1627 </dd>\r
1628 </dl></div>\r
1629 </div>\r
1630 </div>\r
1631 </div>\r
1632 <div id="footnotes"><hr /></div>\r
1633 <div id="footer" lang="de">\r
1634 © 2009-2011 Michael Stapelberg, <a href="/impress.html">Impressum</a>\r
1635 </div>\r
1636 </body>\r
1637 </html>\r