]> git.sur5r.net Git - i3/i3.github.io/blob - docs/ipc.html
Change copyright notice to show 2009-present
[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.10" />\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">September 2017</span>\r
36 <div id="toc">\r
37   <div id="toctitle">Table of Contents</div>\r
38   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>\r
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="tableblock">\r
96 <table rules="all"\r
97 width="100%"\r
98 frame="border"\r
99 cellspacing="0" cellpadding="4">\r
100 <caption class="title">Table 1. Currently implemented message types</caption>\r
101 <col width="10%" />\r
102 <col width="20%" />\r
103 <col width="20%" />\r
104 <col width="50%" />\r
105 <thead>\r
106 <tr>\r
107 <th align="center" valign="top"> Type (numeric) </th>\r
108 <th align="center" valign="top"> Type (name) </th>\r
109 <th align="center" valign="top"> Reply type </th>\r
110 <th align="center" valign="top"> Purpose</th>\r
111 </tr>\r
112 </thead>\r
113 <tbody>\r
114 <tr>\r
115 <td align="center" valign="top"><p class="table">0</p></td>\r
116 <td align="center" valign="top"><p class="table"><tt>RUN_COMMAND</tt></p></td>\r
117 <td align="center" valign="top"><p class="table"><a href="#_command_reply">COMMAND</a></p></td>\r
118 <td align="center" valign="top"><p class="table">Run the payload as an i3 command (like the commands you can bind to keys).</p></td>\r
119 </tr>\r
120 <tr>\r
121 <td align="center" valign="top"><p class="table">1</p></td>\r
122 <td align="center" valign="top"><p class="table"><tt>GET_WORKSPACES</tt></p></td>\r
123 <td align="center" valign="top"><p class="table"><a href="#_workspaces_reply">WORKSPACES</a></p></td>\r
124 <td align="center" valign="top"><p class="table">Get the list of current workspaces.</p></td>\r
125 </tr>\r
126 <tr>\r
127 <td align="center" valign="top"><p class="table">2</p></td>\r
128 <td align="center" valign="top"><p class="table"><tt>SUBSCRIBE</tt></p></td>\r
129 <td align="center" valign="top"><p class="table"><a href="#_subscribe_reply">SUBSCRIBE</a></p></td>\r
130 <td align="center" valign="top"><p class="table">Subscribe this IPC connection to the event types specified in the message payload. See <a href="#events">[events]</a>.</p></td>\r
131 </tr>\r
132 <tr>\r
133 <td align="center" valign="top"><p class="table">3</p></td>\r
134 <td align="center" valign="top"><p class="table"><tt>GET_OUTPUTS</tt></p></td>\r
135 <td align="center" valign="top"><p class="table"><a href="#_outputs_reply">OUTPUTS</a></p></td>\r
136 <td align="center" valign="top"><p class="table">Get the list of current outputs.</p></td>\r
137 </tr>\r
138 <tr>\r
139 <td align="center" valign="top"><p class="table">4</p></td>\r
140 <td align="center" valign="top"><p class="table"><tt>GET_TREE</tt></p></td>\r
141 <td align="center" valign="top"><p class="table"><a href="#_tree_reply">TREE</a></p></td>\r
142 <td align="center" valign="top"><p class="table">Get the i3 layout tree.</p></td>\r
143 </tr>\r
144 <tr>\r
145 <td align="center" valign="top"><p class="table">5</p></td>\r
146 <td align="center" valign="top"><p class="table"><tt>GET_MARKS</tt></p></td>\r
147 <td align="center" valign="top"><p class="table"><a href="#_marks_reply">MARKS</a></p></td>\r
148 <td align="center" valign="top"><p class="table">Gets the names of all currently set marks.</p></td>\r
149 </tr>\r
150 <tr>\r
151 <td align="center" valign="top"><p class="table">6</p></td>\r
152 <td align="center" valign="top"><p class="table"><tt>GET_BAR_CONFIG</tt></p></td>\r
153 <td align="center" valign="top"><p class="table"><a href="#_bar_config_reply">BAR_CONFIG</a></p></td>\r
154 <td align="center" valign="top"><p class="table">Gets the specified bar configuration or the names of all bar configurations if payload is empty.</p></td>\r
155 </tr>\r
156 <tr>\r
157 <td align="center" valign="top"><p class="table">7</p></td>\r
158 <td align="center" valign="top"><p class="table"><tt>GET_VERSION</tt></p></td>\r
159 <td align="center" valign="top"><p class="table"><a href="#_version_reply">VERSION</a></p></td>\r
160 <td align="center" valign="top"><p class="table">Gets the i3 version.</p></td>\r
161 </tr>\r
162 <tr>\r
163 <td align="center" valign="top"><p class="table">8</p></td>\r
164 <td align="center" valign="top"><p class="table"><tt>GET_BINDING_MODES</tt></p></td>\r
165 <td align="center" valign="top"><p class="table"><a href="#_binding_modes_reply">BINDING_MODES</a></p></td>\r
166 <td align="center" valign="top"><p class="table">Gets the names of all currently configured binding modes.</p></td>\r
167 </tr>\r
168 <tr>\r
169 <td align="center" valign="top"><p class="table">9</p></td>\r
170 <td align="center" valign="top"><p class="table"><tt>GET_CONFIG</tt></p></td>\r
171 <td align="center" valign="top"><p class="table"><a href="#_config_reply">CONFIG</a></p></td>\r
172 <td align="center" valign="top"><p class="table">Returns the last loaded i3 config.</p></td>\r
173 </tr>\r
174 <tr>\r
175 <td align="center" valign="top"><p class="table">10</p></td>\r
176 <td align="center" valign="top"><p class="table"><tt>SEND_TICK</tt></p></td>\r
177 <td align="center" valign="top"><p class="table"><a href="#_tick_reply">TICK</a></p></td>\r
178 <td align="center" valign="top"><p class="table">Sends a tick event with the specified payload.</p></td>\r
179 </tr>\r
180 <tr>\r
181 <td align="center" valign="top"><p class="table">11</p></td>\r
182 <td align="center" valign="top"><p class="table"><tt>SYNC</tt></p></td>\r
183 <td align="center" valign="top"><p class="table"><a href="#_sync_reply">SYNC</a></p></td>\r
184 <td align="center" valign="top"><p class="table">Sends an i3 sync event with the specified random value to the specified window.</p></td>\r
185 </tr>\r
186 </tbody>\r
187 </table>\r
188 </div>\r
189 <div class="paragraph"><p>So, a typical message could look like this:</p></div>\r
190 <div class="listingblock">\r
191 <div class="content">\r
192 <pre><tt>"i3-ipc" &lt;message length&gt; &lt;message type&gt; &lt;payload&gt;</tt></pre>\r
193 </div></div>\r
194 <div class="paragraph"><p>Or, as a hexdump:</p></div>\r
195 <div class="listingblock">\r
196 <div class="content">\r
197 <pre><tt>00000000  69 33 2d 69 70 63 04 00  00 00 00 00 00 00 65 78  |i3-ipc........ex|\r
198 00000010  69 74                                             |it|</tt></pre>\r
199 </div></div>\r
200 <div class="paragraph"><p>To generate and send such a message, you could use the following code in Perl:</p></div>\r
201 <div class="listingblock">\r
202 <div class="content">\r
203 <pre><tt>sub format_ipc_command {\r
204     my ($msg) = @_;\r
205     my $len;\r
206     # Get the real byte count (vs. amount of characters)\r
207     { use bytes; $len = length($msg); }\r
208     return "i3-ipc" . pack("LL", $len, 0) . $msg;\r
209 }\r
210 \r
211 $sock-&gt;write(format_ipc_command("exit"));</tt></pre>\r
212 </div></div>\r
213 </div>\r
214 </div>\r
215 <div class="sect1">\r
216 <h2 id="_receiving_replies_from_i3">3. Receiving replies from i3</h2>\r
217 <div class="sectionbody">\r
218 <div class="paragraph"><p>Replies from i3 usually consist of a simple string (the length of the string\r
219 is the message_length, so you can consider them length-prefixed) which in turn\r
220 contain the JSON serialization of a data structure. For example, the\r
221 GET_WORKSPACES message returns an array of workspaces (each workspace is a map\r
222 with certain attributes).</p></div>\r
223 <div class="sect2">\r
224 <h3 id="_reply_format">3.1. Reply format</h3>\r
225 <div class="paragraph"><p>The reply format is identical to the normal message format. There also is\r
226 the magic string, then the message length, then the message type and the\r
227 payload.</p></div>\r
228 <div class="paragraph"><p>The following reply types are implemented:</p></div>\r
229 <div class="dlist"><dl>\r
230 <dt class="hdlist1">\r
231 COMMAND (0)\r
232 </dt>\r
233 <dd>\r
234 <p>\r
235         Confirmation/Error code for the RUN_COMMAND message.\r
236 </p>\r
237 </dd>\r
238 <dt class="hdlist1">\r
239 WORKSPACES (1)\r
240 </dt>\r
241 <dd>\r
242 <p>\r
243         Reply to the GET_WORKSPACES message.\r
244 </p>\r
245 </dd>\r
246 <dt class="hdlist1">\r
247 SUBSCRIBE (2)\r
248 </dt>\r
249 <dd>\r
250 <p>\r
251         Confirmation/Error code for the SUBSCRIBE message.\r
252 </p>\r
253 </dd>\r
254 <dt class="hdlist1">\r
255 OUTPUTS (3)\r
256 </dt>\r
257 <dd>\r
258 <p>\r
259         Reply to the GET_OUTPUTS message.\r
260 </p>\r
261 </dd>\r
262 <dt class="hdlist1">\r
263 TREE (4)\r
264 </dt>\r
265 <dd>\r
266 <p>\r
267         Reply to the GET_TREE message.\r
268 </p>\r
269 </dd>\r
270 <dt class="hdlist1">\r
271 MARKS (5)\r
272 </dt>\r
273 <dd>\r
274 <p>\r
275         Reply to the GET_MARKS message.\r
276 </p>\r
277 </dd>\r
278 <dt class="hdlist1">\r
279 BAR_CONFIG (6)\r
280 </dt>\r
281 <dd>\r
282 <p>\r
283         Reply to the GET_BAR_CONFIG message.\r
284 </p>\r
285 </dd>\r
286 <dt class="hdlist1">\r
287 VERSION (7)\r
288 </dt>\r
289 <dd>\r
290 <p>\r
291         Reply to the GET_VERSION message.\r
292 </p>\r
293 </dd>\r
294 <dt class="hdlist1">\r
295 BINDING_MODES (8)\r
296 </dt>\r
297 <dd>\r
298 <p>\r
299         Reply to the GET_BINDING_MODES message.\r
300 </p>\r
301 </dd>\r
302 <dt class="hdlist1">\r
303 GET_CONFIG (9)\r
304 </dt>\r
305 <dd>\r
306 <p>\r
307         Reply to the GET_CONFIG message.\r
308 </p>\r
309 </dd>\r
310 <dt class="hdlist1">\r
311 TICK (10)\r
312 </dt>\r
313 <dd>\r
314 <p>\r
315         Reply to the SEND_TICK message.\r
316 </p>\r
317 </dd>\r
318 </dl></div>\r
319 </div>\r
320 <div class="sect2">\r
321 <h3 id="_command_reply">3.2. COMMAND reply</h3>\r
322 <div class="paragraph"><p>The reply consists of a list of serialized maps for each command that was\r
323 parsed. Each has the property <tt>success (bool)</tt> and may also include a\r
324 human-readable error message in the property <tt>error (string)</tt>.</p></div>\r
325 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
326 <div class="listingblock">\r
327 <div class="content">\r
328 <pre><tt>[{ "success": true }]</tt></pre>\r
329 </div></div>\r
330 </div>\r
331 <div class="sect2">\r
332 <h3 id="_workspaces_reply">3.3. WORKSPACES reply</h3>\r
333 <div class="paragraph"><p>The reply consists of a serialized list of workspaces. Each workspace has the\r
334 following properties:</p></div>\r
335 <div class="dlist"><dl>\r
336 <dt class="hdlist1">\r
337 num (integer)\r
338 </dt>\r
339 <dd>\r
340 <p>\r
341         The logical number of the workspace. Corresponds to the command\r
342         to switch to this workspace. For named workspaces, this will be -1.\r
343 </p>\r
344 </dd>\r
345 <dt class="hdlist1">\r
346 name (string)\r
347 </dt>\r
348 <dd>\r
349 <p>\r
350         The name of this workspace (by default num+1), as changed by the\r
351         user. Encoded in UTF-8.\r
352 </p>\r
353 </dd>\r
354 <dt class="hdlist1">\r
355 visible (boolean)\r
356 </dt>\r
357 <dd>\r
358 <p>\r
359         Whether this workspace is currently visible on an output (multiple\r
360         workspaces can be visible at the same time).\r
361 </p>\r
362 </dd>\r
363 <dt class="hdlist1">\r
364 focused (boolean)\r
365 </dt>\r
366 <dd>\r
367 <p>\r
368         Whether this workspace currently has the focus (only one workspace\r
369         can have the focus at the same time).\r
370 </p>\r
371 </dd>\r
372 <dt class="hdlist1">\r
373 urgent (boolean)\r
374 </dt>\r
375 <dd>\r
376 <p>\r
377         Whether a window on this workspace has the "urgent" flag set.\r
378 </p>\r
379 </dd>\r
380 <dt class="hdlist1">\r
381 rect (map)\r
382 </dt>\r
383 <dd>\r
384 <p>\r
385         The rectangle of this workspace (equals the rect of the output it\r
386         is on), consists of x, y, width, height.\r
387 </p>\r
388 </dd>\r
389 <dt class="hdlist1">\r
390 output (string)\r
391 </dt>\r
392 <dd>\r
393 <p>\r
394         The video output this workspace is on (LVDS1, VGA1, …).\r
395 </p>\r
396 </dd>\r
397 </dl></div>\r
398 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
399 <div class="listingblock">\r
400 <div class="content">\r
401 <pre><tt>[\r
402  {\r
403   "num": 0,\r
404   "name": "1",\r
405   "visible": true,\r
406   "focused": true,\r
407   "urgent": false,\r
408   "rect": {\r
409    "x": 0,\r
410    "y": 0,\r
411    "width": 1280,\r
412    "height": 800\r
413   },\r
414   "output": "LVDS1"\r
415  },\r
416  {\r
417   "num": 1,\r
418   "name": "2",\r
419   "visible": false,\r
420   "focused": false,\r
421   "urgent": false,\r
422   "rect": {\r
423    "x": 0,\r
424    "y": 0,\r
425    "width": 1280,\r
426    "height": 800\r
427   },\r
428   "output": "LVDS1"\r
429  }\r
430 ]</tt></pre>\r
431 </div></div>\r
432 </div>\r
433 <div class="sect2">\r
434 <h3 id="_subscribe_reply">3.4. SUBSCRIBE reply</h3>\r
435 <div class="paragraph"><p>The reply consists of a single serialized map. The only property is\r
436 <tt>success (bool)</tt>, indicating whether the subscription was successful (the\r
437 default) or whether a JSON parse error occurred.</p></div>\r
438 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
439 <div class="listingblock">\r
440 <div class="content">\r
441 <pre><tt>{ "success": true }</tt></pre>\r
442 </div></div>\r
443 </div>\r
444 <div class="sect2">\r
445 <h3 id="_outputs_reply">3.5. OUTPUTS reply</h3>\r
446 <div class="paragraph"><p>The reply consists of a serialized list of outputs. Each output has the\r
447 following properties:</p></div>\r
448 <div class="dlist"><dl>\r
449 <dt class="hdlist1">\r
450 name (string)\r
451 </dt>\r
452 <dd>\r
453 <p>\r
454         The name of this output (as seen in <tt>xrandr(1)</tt>). Encoded in UTF-8.\r
455 </p>\r
456 </dd>\r
457 <dt class="hdlist1">\r
458 active (boolean)\r
459 </dt>\r
460 <dd>\r
461 <p>\r
462         Whether this output is currently active (has a valid mode).\r
463 </p>\r
464 </dd>\r
465 <dt class="hdlist1">\r
466 primary (boolean)\r
467 </dt>\r
468 <dd>\r
469 <p>\r
470         Whether this output is currently the primary output.\r
471 </p>\r
472 </dd>\r
473 <dt class="hdlist1">\r
474 current_workspace (string)\r
475 </dt>\r
476 <dd>\r
477 <p>\r
478         The name of the current workspace that is visible on this output. <tt>null</tt> if\r
479         the output is not active.\r
480 </p>\r
481 </dd>\r
482 <dt class="hdlist1">\r
483 rect (map)\r
484 </dt>\r
485 <dd>\r
486 <p>\r
487         The rectangle of this output (equals the rect of the output it\r
488         is on), consists of x, y, width, height.\r
489 </p>\r
490 </dd>\r
491 </dl></div>\r
492 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
493 <div class="listingblock">\r
494 <div class="content">\r
495 <pre><tt>[\r
496  {\r
497   "name": "LVDS1",\r
498   "active": true,\r
499   "current_workspace": "4",\r
500   "rect": {\r
501    "x": 0,\r
502    "y": 0,\r
503    "width": 1280,\r
504    "height": 800\r
505   }\r
506  },\r
507  {\r
508   "name": "VGA1",\r
509   "active": true,\r
510   "current_workspace": "1",\r
511   "rect": {\r
512    "x": 1280,\r
513    "y": 0,\r
514    "width": 1280,\r
515    "height": 1024\r
516   }\r
517  }\r
518 ]</tt></pre>\r
519 </div></div>\r
520 </div>\r
521 <div class="sect2">\r
522 <h3 id="_tree_reply">3.6. TREE reply</h3>\r
523 <div class="paragraph"><p>The reply consists of a serialized tree. Each node in the tree (representing\r
524 one container) has at least the properties listed below. While the nodes might\r
525 have more properties, please do not use any properties which are not documented\r
526 here. They are not yet finalized and will probably change!</p></div>\r
527 <div class="dlist"><dl>\r
528 <dt class="hdlist1">\r
529 id (integer)\r
530 </dt>\r
531 <dd>\r
532 <p>\r
533         The internal ID (actually a C pointer value) of this container. Do not\r
534         make any assumptions about it. You can use it to (re-)identify and\r
535         address containers when talking to i3.\r
536 </p>\r
537 </dd>\r
538 <dt class="hdlist1">\r
539 name (string)\r
540 </dt>\r
541 <dd>\r
542 <p>\r
543         The internal name of this container. For all containers which are part\r
544         of the tree structure down to the workspace contents, this is set to a\r
545         nice human-readable name of the container.\r
546         For containers that have an X11 window, the content is the title\r
547         (_NET_WM_NAME property) of that window.\r
548         For all other containers, the content is not defined (yet).\r
549 </p>\r
550 </dd>\r
551 <dt class="hdlist1">\r
552 type (string)\r
553 </dt>\r
554 <dd>\r
555 <p>\r
556         Type of this container. Can be one of "root", "output", "con",\r
557         "floating_con", "workspace" or "dockarea".\r
558 </p>\r
559 </dd>\r
560 <dt class="hdlist1">\r
561 border (string)\r
562 </dt>\r
563 <dd>\r
564 <p>\r
565         Can be either "normal", "none" or "pixel", depending on the\r
566         container’s border style.\r
567 </p>\r
568 </dd>\r
569 <dt class="hdlist1">\r
570 current_border_width (integer)\r
571 </dt>\r
572 <dd>\r
573 <p>\r
574         Number of pixels of the border width.\r
575 </p>\r
576 </dd>\r
577 <dt class="hdlist1">\r
578 layout (string)\r
579 </dt>\r
580 <dd>\r
581 <p>\r
582         Can be either "splith", "splitv", "stacked", "tabbed", "dockarea" or\r
583         "output".\r
584         Other values might be possible in the future, should we add new\r
585         layouts.\r
586 </p>\r
587 </dd>\r
588 <dt class="hdlist1">\r
589 orientation (string)\r
590 </dt>\r
591 <dd>\r
592 <p>\r
593         Can be either "none" (for non-split containers), "horizontal" or\r
594         "vertical".\r
595         THIS FIELD IS OBSOLETE. It is still present, but your code should not\r
596         use it. Instead, rely on the layout field.\r
597 </p>\r
598 </dd>\r
599 <dt class="hdlist1">\r
600 percent (float)\r
601 </dt>\r
602 <dd>\r
603 <p>\r
604         The percentage which this container takes in its parent. A value of\r
605         <tt>null</tt> means that the percent property does not make sense for this\r
606         container, for example for the root container.\r
607 </p>\r
608 </dd>\r
609 <dt class="hdlist1">\r
610 rect (map)\r
611 </dt>\r
612 <dd>\r
613 <p>\r
614         The absolute display coordinates for this container. Display\r
615         coordinates means that when you have two 1600x1200 monitors on a single\r
616         X11 Display (the standard way), the coordinates of the first window on\r
617         the second monitor are <tt>{ "x": 1600, "y": 0, "width": 1600, "height":\r
618         1200 }</tt>.\r
619 </p>\r
620 </dd>\r
621 <dt class="hdlist1">\r
622 window_rect (map)\r
623 </dt>\r
624 <dd>\r
625 <p>\r
626         The coordinates of the <strong>actual client window</strong> inside its container.\r
627         These coordinates are relative to the container and do not include the\r
628         window decoration (which is actually rendered on the parent container).\r
629         So, when using the <tt>default</tt> layout, you will have a 2 pixel border on\r
630         each side, making the window_rect <tt>{ "x": 2, "y": 0, "width": 632,\r
631         "height": 366 }</tt> (for example).\r
632 </p>\r
633 </dd>\r
634 <dt class="hdlist1">\r
635 deco_rect (map)\r
636 </dt>\r
637 <dd>\r
638 <p>\r
639         The coordinates of the <strong>window decoration</strong> inside its container. These\r
640         coordinates are relative to the container and do not include the actual\r
641         client window.\r
642 </p>\r
643 </dd>\r
644 <dt class="hdlist1">\r
645 geometry (map)\r
646 </dt>\r
647 <dd>\r
648 <p>\r
649         The original geometry the window specified when i3 mapped it. Used when\r
650         switching a window to floating mode, for example.\r
651 </p>\r
652 </dd>\r
653 <dt class="hdlist1">\r
654 window (integer)\r
655 </dt>\r
656 <dd>\r
657 <p>\r
658         The X11 window ID of the <strong>actual client window</strong> inside this container.\r
659         This field is set to null for split containers or otherwise empty\r
660         containers. This ID corresponds to what xwininfo(1) and other\r
661         X11-related tools display (usually in hex).\r
662 </p>\r
663 </dd>\r
664 <dt class="hdlist1">\r
665 window_properties (map)\r
666 </dt>\r
667 <dd>\r
668 <p>\r
669         X11 window properties title, instance, class, window_role and transient_for.\r
670 </p>\r
671 </dd>\r
672 <dt class="hdlist1">\r
673 urgent (bool)\r
674 </dt>\r
675 <dd>\r
676 <p>\r
677         Whether this container (window, split container, floating container or\r
678         workspace) has the urgency hint set, directly or indirectly. All parent\r
679         containers up until the workspace container will be marked urgent if they\r
680         have at least one urgent child.\r
681 </p>\r
682 </dd>\r
683 <dt class="hdlist1">\r
684 focused (bool)\r
685 </dt>\r
686 <dd>\r
687 <p>\r
688         Whether this container is currently focused.\r
689 </p>\r
690 </dd>\r
691 <dt class="hdlist1">\r
692 focus (array of integer)\r
693 </dt>\r
694 <dd>\r
695 <p>\r
696         List of child node IDs (see <tt>nodes</tt>, <tt>floating_nodes</tt> and <tt>id</tt>) in focus\r
697         order. Traversing the tree by following the first entry in this array\r
698         will result in eventually reaching the one node with <tt>focused</tt> set to\r
699         true.\r
700 </p>\r
701 </dd>\r
702 <dt class="hdlist1">\r
703 nodes (array of node)\r
704 </dt>\r
705 <dd>\r
706 <p>\r
707         The tiling (i.e. non-floating) child containers of this node.\r
708 </p>\r
709 </dd>\r
710 <dt class="hdlist1">\r
711 floating_nodes (array of node)\r
712 </dt>\r
713 <dd>\r
714 <p>\r
715         The floating child containers of this node. Only non-empty on nodes with\r
716         type <tt>workspace</tt>.\r
717 </p>\r
718 </dd>\r
719 </dl></div>\r
720 <div class="paragraph"><p>Please note that in the following example, I have left out some keys/values\r
721 which are not relevant for the type of the node. Otherwise, the example would\r
722 be by far too long (it already is quite long, despite showing only 1 window and\r
723 one dock window).</p></div>\r
724 <div class="paragraph"><p>It is useful to have an overview of the structure before taking a look at the\r
725 JSON dump:</p></div>\r
726 <div class="ulist"><ul>\r
727 <li>\r
728 <p>\r
729 root\r
730 </p>\r
731 <div class="ulist"><ul>\r
732 <li>\r
733 <p>\r
734 LVDS1\r
735 </p>\r
736 <div class="ulist"><ul>\r
737 <li>\r
738 <p>\r
739 topdock\r
740 </p>\r
741 </li>\r
742 <li>\r
743 <p>\r
744 content\r
745 </p>\r
746 <div class="ulist"><ul>\r
747 <li>\r
748 <p>\r
749 workspace 1\r
750 </p>\r
751 <div class="ulist"><ul>\r
752 <li>\r
753 <p>\r
754 window 1\r
755 </p>\r
756 </li>\r
757 </ul></div>\r
758 </li>\r
759 </ul></div>\r
760 </li>\r
761 <li>\r
762 <p>\r
763 bottomdock\r
764 </p>\r
765 <div class="ulist"><ul>\r
766 <li>\r
767 <p>\r
768 dock window 1\r
769 </p>\r
770 </li>\r
771 </ul></div>\r
772 </li>\r
773 </ul></div>\r
774 </li>\r
775 <li>\r
776 <p>\r
777 VGA1\r
778 </p>\r
779 </li>\r
780 </ul></div>\r
781 </li>\r
782 </ul></div>\r
783 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
784 <div class="listingblock">\r
785 <div class="content">\r
786 <pre><tt>{\r
787  "id": 6875648,\r
788  "name": "root",\r
789  "rect": {\r
790    "x": 0,\r
791    "y": 0,\r
792    "width": 1280,\r
793    "height": 800\r
794  },\r
795  "nodes": [\r
796 \r
797    {\r
798     "id": 6878320,\r
799     "name": "LVDS1",\r
800     "layout": "output",\r
801     "rect": {\r
802       "x": 0,\r
803       "y": 0,\r
804       "width": 1280,\r
805       "height": 800\r
806     },\r
807     "nodes": [\r
808 \r
809       {\r
810        "id": 6878784,\r
811        "name": "topdock",\r
812        "layout": "dockarea",\r
813        "orientation": "vertical",\r
814        "rect": {\r
815          "x": 0,\r
816          "y": 0,\r
817          "width": 1280,\r
818          "height": 0\r
819        }\r
820       },\r
821 \r
822       {\r
823        "id": 6879344,\r
824        "name": "content",\r
825        "rect": {\r
826          "x": 0,\r
827          "y": 0,\r
828          "width": 1280,\r
829          "height": 782\r
830        },\r
831        "nodes": [\r
832 \r
833          {\r
834           "id": 6880464,\r
835           "name": "1",\r
836           "orientation": "horizontal",\r
837           "rect": {\r
838             "x": 0,\r
839             "y": 0,\r
840             "width": 1280,\r
841             "height": 782\r
842           },\r
843           "window_properties": {\r
844             "class": "Evince",\r
845             "instance": "evince",\r
846             "title": "Properties",\r
847             "transient_for": 52428808\r
848           },\r
849           "floating_nodes": [],\r
850           "nodes": [\r
851 \r
852             {\r
853              "id": 6929968,\r
854              "name": "#aa0000",\r
855              "border": "normal",\r
856              "percent": 1,\r
857              "rect": {\r
858                "x": 0,\r
859                "y": 18,\r
860                "width": 1280,\r
861                "height": 782\r
862              }\r
863             }\r
864 \r
865           ]\r
866          }\r
867 \r
868        ]\r
869       },\r
870 \r
871       {\r
872        "id": 6880208,\r
873        "name": "bottomdock",\r
874        "layout": "dockarea",\r
875        "orientation": "vertical",\r
876        "rect": {\r
877          "x": 0,\r
878          "y": 782,\r
879          "width": 1280,\r
880          "height": 18\r
881        },\r
882        "nodes": [\r
883 \r
884          {\r
885           "id": 6931312,\r
886           "name": "#00aa00",\r
887           "percent": 1,\r
888           "rect": {\r
889             "x": 0,\r
890             "y": 782,\r
891             "width": 1280,\r
892             "height": 18\r
893           }\r
894          }\r
895 \r
896        ]\r
897       }\r
898     ]\r
899    }\r
900  ]\r
901 }</tt></pre>\r
902 </div></div>\r
903 </div>\r
904 <div class="sect2">\r
905 <h3 id="_marks_reply">3.7. MARKS reply</h3>\r
906 <div class="paragraph"><p>The reply consists of a single array of strings for each container that has a\r
907 mark. A mark can only be set on one container, so the array is unique.\r
908 The order of that array is undefined.</p></div>\r
909 <div class="paragraph"><p>If no window has a mark the response will be the empty array [].</p></div>\r
910 </div>\r
911 <div class="sect2">\r
912 <h3 id="_bar_config_reply">3.8. BAR_CONFIG reply</h3>\r
913 <div class="paragraph"><p>This can be used by third-party workspace bars (especially i3bar, but others\r
914 are free to implement compatible alternatives) to get the <tt>bar</tt> block\r
915 configuration from i3.</p></div>\r
916 <div class="paragraph"><p>Depending on the input, the reply is either:</p></div>\r
917 <div class="dlist"><dl>\r
918 <dt class="hdlist1">\r
919 empty input\r
920 </dt>\r
921 <dd>\r
922 <p>\r
923         An array of configured bar IDs\r
924 </p>\r
925 </dd>\r
926 <dt class="hdlist1">\r
927 Bar ID\r
928 </dt>\r
929 <dd>\r
930 <p>\r
931         A JSON map containing the configuration for the specified bar.\r
932 </p>\r
933 </dd>\r
934 </dl></div>\r
935 <div class="paragraph"><p>Each bar configuration has the following properties:</p></div>\r
936 <div class="dlist"><dl>\r
937 <dt class="hdlist1">\r
938 id (string)\r
939 </dt>\r
940 <dd>\r
941 <p>\r
942         The ID for this bar. Included in case you request multiple\r
943         configurations and want to differentiate the different replies.\r
944 </p>\r
945 </dd>\r
946 <dt class="hdlist1">\r
947 mode (string)\r
948 </dt>\r
949 <dd>\r
950 <p>\r
951         Either <tt>dock</tt> (the bar sets the dock window type) or <tt>hide</tt> (the bar\r
952         does not show unless a specific key is pressed).\r
953 </p>\r
954 </dd>\r
955 <dt class="hdlist1">\r
956 position (string)\r
957 </dt>\r
958 <dd>\r
959 <p>\r
960         Either <tt>bottom</tt> or <tt>top</tt> at the moment.\r
961 </p>\r
962 </dd>\r
963 <dt class="hdlist1">\r
964 status_command (string)\r
965 </dt>\r
966 <dd>\r
967 <p>\r
968         Command which will be run to generate a statusline. Each line on stdout\r
969         of this command will be displayed in the bar. At the moment, no\r
970         formatting is supported.\r
971 </p>\r
972 </dd>\r
973 <dt class="hdlist1">\r
974 font (string)\r
975 </dt>\r
976 <dd>\r
977 <p>\r
978         The font to use for text on the bar.\r
979 </p>\r
980 </dd>\r
981 <dt class="hdlist1">\r
982 workspace_buttons (boolean)\r
983 </dt>\r
984 <dd>\r
985 <p>\r
986         Display workspace buttons or not? Defaults to true.\r
987 </p>\r
988 </dd>\r
989 <dt class="hdlist1">\r
990 binding_mode_indicator (boolean)\r
991 </dt>\r
992 <dd>\r
993 <p>\r
994         Display the mode indicator or not? Defaults to true.\r
995 </p>\r
996 </dd>\r
997 <dt class="hdlist1">\r
998 verbose (boolean)\r
999 </dt>\r
1000 <dd>\r
1001 <p>\r
1002         Should the bar enable verbose output for debugging? Defaults to false.\r
1003 </p>\r
1004 </dd>\r
1005 <dt class="hdlist1">\r
1006 colors (map)\r
1007 </dt>\r
1008 <dd>\r
1009 <p>\r
1010         Contains key/value pairs of colors. Each value is a color code in hex,\r
1011         formatted #rrggbb (like in HTML).\r
1012 </p>\r
1013 </dd>\r
1014 </dl></div>\r
1015 <div class="paragraph"><p>The following colors can be configured at the moment:</p></div>\r
1016 <div class="dlist"><dl>\r
1017 <dt class="hdlist1">\r
1018 background\r
1019 </dt>\r
1020 <dd>\r
1021 <p>\r
1022         Background color of the bar.\r
1023 </p>\r
1024 </dd>\r
1025 <dt class="hdlist1">\r
1026 statusline\r
1027 </dt>\r
1028 <dd>\r
1029 <p>\r
1030         Text color to be used for the statusline.\r
1031 </p>\r
1032 </dd>\r
1033 <dt class="hdlist1">\r
1034 separator\r
1035 </dt>\r
1036 <dd>\r
1037 <p>\r
1038         Text color to be used for the separator.\r
1039 </p>\r
1040 </dd>\r
1041 <dt class="hdlist1">\r
1042 focused_background\r
1043 </dt>\r
1044 <dd>\r
1045 <p>\r
1046         Background color of the bar on the currently focused monitor output.\r
1047 </p>\r
1048 </dd>\r
1049 <dt class="hdlist1">\r
1050 focused_statusline\r
1051 </dt>\r
1052 <dd>\r
1053 <p>\r
1054         Text color to be used for the statusline on the currently focused\r
1055         monitor output.\r
1056 </p>\r
1057 </dd>\r
1058 <dt class="hdlist1">\r
1059 focused_separator\r
1060 </dt>\r
1061 <dd>\r
1062 <p>\r
1063         Text color to be used for the separator on the currently focused\r
1064         monitor output.\r
1065 </p>\r
1066 </dd>\r
1067 <dt class="hdlist1">\r
1068 focused_workspace_text/focused_workspace_bg/focused_workspace_border\r
1069 </dt>\r
1070 <dd>\r
1071 <p>\r
1072         Text/background/border color for a workspace button when the workspace\r
1073         has focus.\r
1074 </p>\r
1075 </dd>\r
1076 <dt class="hdlist1">\r
1077 active_workspace_text/active_workspace_bg/active_workspace_border\r
1078 </dt>\r
1079 <dd>\r
1080 <p>\r
1081         Text/background/border color for a workspace button when the workspace\r
1082         is active (visible) on some output, but the focus is on another one.\r
1083         You can only tell this apart from the focused workspace when you are\r
1084         using multiple monitors.\r
1085 </p>\r
1086 </dd>\r
1087 <dt class="hdlist1">\r
1088 inactive_workspace_text/inactive_workspace_bg/inactive_workspace_border\r
1089 </dt>\r
1090 <dd>\r
1091 <p>\r
1092         Text/background/border color for a workspace button when the workspace\r
1093         does not have focus and is not active (visible) on any output. This\r
1094         will be the case for most workspaces.\r
1095 </p>\r
1096 </dd>\r
1097 <dt class="hdlist1">\r
1098 urgent_workspace_text/urgent_workspace_bg/urgent_workspace_border\r
1099 </dt>\r
1100 <dd>\r
1101 <p>\r
1102         Text/background/border color for workspaces which contain at least one\r
1103         window with the urgency hint set.\r
1104 </p>\r
1105 </dd>\r
1106 <dt class="hdlist1">\r
1107 binding_mode_text/binding_mode_bg/binding_mode_border\r
1108 </dt>\r
1109 <dd>\r
1110 <p>\r
1111         Text/background/border color for the binding mode indicator.\r
1112 </p>\r
1113 </dd>\r
1114 </dl></div>\r
1115 <div class="paragraph"><p><strong>Example of configured bars:</strong></p></div>\r
1116 <div class="listingblock">\r
1117 <div class="content">\r
1118 <pre><tt>["bar-bxuqzf"]</tt></pre>\r
1119 </div></div>\r
1120 <div class="paragraph"><p><strong>Example of bar configuration:</strong></p></div>\r
1121 <div class="listingblock">\r
1122 <div class="content">\r
1123 <pre><tt>{\r
1124  "id": "bar-bxuqzf",\r
1125  "mode": "dock",\r
1126  "position": "bottom",\r
1127  "status_command": "i3status",\r
1128  "font": "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1",\r
1129  "workspace_buttons": true,\r
1130  "binding_mode_indicator": true,\r
1131  "verbose": false,\r
1132  "colors": {\r
1133    "background": "#c0c0c0",\r
1134    "statusline": "#00ff00",\r
1135    "focused_workspace_text": "#ffffff",\r
1136    "focused_workspace_bg": "#000000"\r
1137  }\r
1138 }</tt></pre>\r
1139 </div></div>\r
1140 </div>\r
1141 <div class="sect2">\r
1142 <h3 id="_version_reply">3.9. VERSION reply</h3>\r
1143 <div class="paragraph"><p>The reply consists of a single JSON dictionary with the following keys:</p></div>\r
1144 <div class="dlist"><dl>\r
1145 <dt class="hdlist1">\r
1146 major (integer)\r
1147 </dt>\r
1148 <dd>\r
1149 <p>\r
1150         The major version of i3, such as <tt>4</tt>.\r
1151 </p>\r
1152 </dd>\r
1153 <dt class="hdlist1">\r
1154 minor (integer)\r
1155 </dt>\r
1156 <dd>\r
1157 <p>\r
1158         The minor version of i3, such as <tt>2</tt>. Changes in the IPC interface (new\r
1159         features) will only occur with new minor (or major) releases. However,\r
1160         bugfixes might be introduced in patch releases, too.\r
1161 </p>\r
1162 </dd>\r
1163 <dt class="hdlist1">\r
1164 patch (integer)\r
1165 </dt>\r
1166 <dd>\r
1167 <p>\r
1168         The patch version of i3, such as <tt>1</tt> (when the complete version is\r
1169         <tt>4.2.1</tt>). For versions such as <tt>4.2</tt>, patch will be set to <tt>0</tt>.\r
1170 </p>\r
1171 </dd>\r
1172 <dt class="hdlist1">\r
1173 human_readable (string)\r
1174 </dt>\r
1175 <dd>\r
1176 <p>\r
1177         A human-readable version of i3 containing the precise git version,\r
1178         build date and branch name. When you need to display the i3 version to\r
1179         your users, use the human-readable version whenever possible (since\r
1180         this is what <tt>i3 --version</tt> displays, too).\r
1181 </p>\r
1182 </dd>\r
1183 <dt class="hdlist1">\r
1184 loaded_config_file_name (string)\r
1185 </dt>\r
1186 <dd>\r
1187 <p>\r
1188         The current config path.\r
1189 </p>\r
1190 </dd>\r
1191 </dl></div>\r
1192 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1193 <div class="listingblock">\r
1194 <div class="content">\r
1195 <pre><tt>{\r
1196    "human_readable" : "4.2-169-gf80b877 (2012-08-05, branch \"next\")",\r
1197    "loaded_config_file_name" : "/home/hwangcc23/.i3/config",\r
1198    "minor" : 2,\r
1199    "patch" : 0,\r
1200    "major" : 4\r
1201 }</tt></pre>\r
1202 </div></div>\r
1203 </div>\r
1204 <div class="sect2">\r
1205 <h3 id="_binding_modes_reply">3.10. BINDING_MODES reply</h3>\r
1206 <div class="paragraph"><p>The reply consists of an array of all currently configured binding modes.</p></div>\r
1207 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1208 <div class="listingblock">\r
1209 <div class="content">\r
1210 <pre><tt>["default", "resize"]</tt></pre>\r
1211 </div></div>\r
1212 </div>\r
1213 <div class="sect2">\r
1214 <h3 id="_config_reply">3.11. CONFIG reply</h3>\r
1215 <div class="paragraph"><p>The config reply is a map which currently only contains the "config" member,\r
1216 which is a string containing the config file as loaded by i3 most recently.</p></div>\r
1217 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1218 <div class="listingblock">\r
1219 <div class="content">\r
1220 <pre><tt>{ "config": "font pango:monospace 8\nbindsym Mod4+q exit\n" }</tt></pre>\r
1221 </div></div>\r
1222 </div>\r
1223 <div class="sect2">\r
1224 <h3 id="_tick_reply">3.12. TICK reply</h3>\r
1225 <div class="paragraph"><p>The reply is a map containing the "success" member. After the reply was\r
1226 received, the tick event has been written to all IPC connections which subscribe\r
1227 to tick events. UNIX sockets are usually buffered, but you can be certain that\r
1228 once you receive the tick event you just triggered, you must have received all\r
1229 events generated prior to the <tt>SEND_TICK</tt> message (happened-before relation).</p></div>\r
1230 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1231 <div class="listingblock">\r
1232 <div class="content">\r
1233 <pre><tt>{ "success": true }</tt></pre>\r
1234 </div></div>\r
1235 </div>\r
1236 <div class="sect2">\r
1237 <h3 id="_sync_reply">3.13. SYNC reply</h3>\r
1238 <div class="paragraph"><p>The reply is a map containing the "success" member. After the reply was\r
1239 received, the <a href="https://i3wm.org/docs/testsuite.html#i3_sync">i3 sync message</a> was\r
1240 responded to.</p></div>\r
1241 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1242 <div class="listingblock">\r
1243 <div class="content">\r
1244 <pre><tt>{ "success": true }</tt></pre>\r
1245 </div></div>\r
1246 </div>\r
1247 </div>\r
1248 </div>\r
1249 <div class="sect1">\r
1250 <h2 id="_events">4. Events</h2>\r
1251 <div class="sectionbody">\r
1252 <div class="paragraph" id="events"><p>To get informed when certain things happen in i3, clients can subscribe to\r
1253 events. Events consist of a name (like "workspace") and an event reply type\r
1254 (like I3_IPC_EVENT_WORKSPACE). The events sent by i3 are in the same format\r
1255 as replies to specific commands. However, the highest bit of the message type\r
1256 is set to 1 to indicate that this is an event reply instead of a normal reply.</p></div>\r
1257 <div class="paragraph"><p>Caveat: As soon as you subscribe to an event, it is not guaranteed any longer\r
1258 that the requests to i3 are processed in order. This means, the following\r
1259 situation can happen: You send a GET_WORKSPACES request but you receive a\r
1260 "workspace" event before receiving the reply to GET_WORKSPACES. If your\r
1261 program does not want to cope which such kinds of race conditions (an\r
1262 event based library may not have a problem here), I suggest you create a\r
1263 separate connection to receive events.</p></div>\r
1264 <div class="paragraph"><p>If an event message needs to be sent and the socket is not writeable (write\r
1265 returns EAGAIN, happens when the socket doesn&#8217;t have enough buffer space for\r
1266 writing new data) then i3 uses a queue system to store outgoing messages for\r
1267 each client. This is combined with a timer: if the message queue for a client is\r
1268 not empty and no data where successfully written in the past 10 seconds, the\r
1269 connection is killed. Practically, this means that your client should try to\r
1270 always read events from the socket to avoid having its connection closed.</p></div>\r
1271 <div class="sect2">\r
1272 <h3 id="_subscribing_to_events">4.1. Subscribing to events</h3>\r
1273 <div class="paragraph"><p>By sending a message of type SUBSCRIBE with a JSON-encoded array as payload\r
1274 you can register to an event.</p></div>\r
1275 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1276 <div class="listingblock">\r
1277 <div class="content">\r
1278 <pre><tt>type: SUBSCRIBE\r
1279 payload: [ "workspace", "output" ]</tt></pre>\r
1280 </div></div>\r
1281 </div>\r
1282 <div class="sect2">\r
1283 <h3 id="_available_events">4.2. Available events</h3>\r
1284 <div class="paragraph"><p>The numbers in parenthesis is the event type (keep in mind that you need to\r
1285 strip the highest bit first).</p></div>\r
1286 <div class="dlist"><dl>\r
1287 <dt class="hdlist1">\r
1288 workspace (0)\r
1289 </dt>\r
1290 <dd>\r
1291 <p>\r
1292         Sent when the user switches to a different workspace, when a new\r
1293         workspace is initialized or when a workspace is removed (because the\r
1294         last client vanished).\r
1295 </p>\r
1296 </dd>\r
1297 <dt class="hdlist1">\r
1298 output (1)\r
1299 </dt>\r
1300 <dd>\r
1301 <p>\r
1302         Sent when RandR issues a change notification (of either screens,\r
1303         outputs, CRTCs or output properties).\r
1304 </p>\r
1305 </dd>\r
1306 <dt class="hdlist1">\r
1307 mode (2)\r
1308 </dt>\r
1309 <dd>\r
1310 <p>\r
1311         Sent whenever i3 changes its binding mode.\r
1312 </p>\r
1313 </dd>\r
1314 <dt class="hdlist1">\r
1315 window (3)\r
1316 </dt>\r
1317 <dd>\r
1318 <p>\r
1319         Sent when a client&#8217;s window is successfully reparented (that is when i3\r
1320         has finished fitting it into a container), when a window received input\r
1321         focus or when certain properties of the window have changed.\r
1322 </p>\r
1323 </dd>\r
1324 <dt class="hdlist1">\r
1325 barconfig_update (4)\r
1326 </dt>\r
1327 <dd>\r
1328 <p>\r
1329     Sent when the hidden_state or mode field in the barconfig of any bar\r
1330     instance was updated and when the config is reloaded.\r
1331 </p>\r
1332 </dd>\r
1333 <dt class="hdlist1">\r
1334 binding (5)\r
1335 </dt>\r
1336 <dd>\r
1337 <p>\r
1338         Sent when a configured command binding is triggered with the keyboard or\r
1339         mouse\r
1340 </p>\r
1341 </dd>\r
1342 <dt class="hdlist1">\r
1343 shutdown (6)\r
1344 </dt>\r
1345 <dd>\r
1346 <p>\r
1347         Sent when the ipc shuts down because of a restart or exit by user command\r
1348 </p>\r
1349 </dd>\r
1350 <dt class="hdlist1">\r
1351 tick (7)\r
1352 </dt>\r
1353 <dd>\r
1354 <p>\r
1355         Sent when the ipc client subscribes to the tick event (with <tt>"first":\r
1356         true</tt>) or when any ipc client sends a SEND_TICK message (with <tt>"first":\r
1357         false</tt>).\r
1358 </p>\r
1359 </dd>\r
1360 </dl></div>\r
1361 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1362 <div class="listingblock">\r
1363 <div class="content">\r
1364 <pre><tt># the appropriate 4 bytes read from the socket are stored in $input\r
1365 \r
1366 # unpack a 32-bit unsigned integer\r
1367 my $message_type = unpack("L", $input);\r
1368 \r
1369 # check if the highest bit is 1\r
1370 my $is_event = (($message_type &gt;&gt; 31) == 1);\r
1371 \r
1372 # use the other bits\r
1373 my $event_type = ($message_type &amp; 0x7F);\r
1374 \r
1375 if ($is_event) {\r
1376   say "Received event of type $event_type";\r
1377 }</tt></pre>\r
1378 </div></div>\r
1379 </div>\r
1380 <div class="sect2">\r
1381 <h3 id="_workspace_event">4.3. workspace event</h3>\r
1382 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1383 <tt>change (string)</tt> which indicates the type of the change ("focus", "init",\r
1384 "empty", "urgent", "reload", "rename", "restored", "move"). A\r
1385 <tt>current (object)</tt> property will be present with the affected workspace\r
1386 whenever the type of event affects a workspace (otherwise, it will be +null).</p></div>\r
1387 <div class="paragraph"><p>When the change is "focus", an <tt>old (object)</tt> property will be present with the\r
1388 previous workspace.  When the first switch occurs (when i3 focuses the\r
1389 workspace visible at the beginning) there is no previous workspace, and the\r
1390 <tt>old</tt> property will be set to <tt>null</tt>.  Also note that if the previous is empty\r
1391 it will get destroyed when switching, but will still be present in the "old"\r
1392 property.</p></div>\r
1393 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1394 <div class="listingblock">\r
1395 <div class="content">\r
1396 <pre><tt>{\r
1397  "change": "focus",\r
1398  "current": {\r
1399   "id": 28489712,\r
1400   "type": "workspace",\r
1401   ...\r
1402  }\r
1403  "old": {\r
1404   "id": 28489715,\r
1405   "type": "workspace",\r
1406   ...\r
1407  }\r
1408 }</tt></pre>\r
1409 </div></div>\r
1410 </div>\r
1411 <div class="sect2">\r
1412 <h3 id="_output_event">4.4. output event</h3>\r
1413 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1414 <tt>change (string)</tt> which indicates the type of the change (currently only\r
1415 "unspecified").</p></div>\r
1416 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1417 <div class="listingblock">\r
1418 <div class="content">\r
1419 <pre><tt>{ "change": "unspecified" }</tt></pre>\r
1420 </div></div>\r
1421 </div>\r
1422 <div class="sect2">\r
1423 <h3 id="_mode_event">4.5. mode event</h3>\r
1424 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1425 <tt>change (string)</tt> which holds the name of current mode in use. The name\r
1426 is the same as specified in config when creating a mode. The default\r
1427 mode is simply named default. It contains a second property, <tt>pango_markup</tt>, which\r
1428 defines whether pango markup shall be used for displaying this mode.</p></div>\r
1429 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1430 <div class="listingblock">\r
1431 <div class="content">\r
1432 <pre><tt>{\r
1433   "change": "default",\r
1434   "pango_markup": true\r
1435 }</tt></pre>\r
1436 </div></div>\r
1437 </div>\r
1438 <div class="sect2">\r
1439 <h3 id="_window_event">4.6. window event</h3>\r
1440 <div class="paragraph"><p>This event consists of a single serialized map containing a property\r
1441 <tt>change (string)</tt> which indicates the type of the change</p></div>\r
1442 <div class="ulist"><ul>\r
1443 <li>\r
1444 <p>\r
1445 <tt>new</tt> – the window has become managed by i3\r
1446 </p>\r
1447 </li>\r
1448 <li>\r
1449 <p>\r
1450 <tt>close</tt> – the window has closed\r
1451 </p>\r
1452 </li>\r
1453 <li>\r
1454 <p>\r
1455 <tt>focus</tt> – the window has received input focus\r
1456 </p>\r
1457 </li>\r
1458 <li>\r
1459 <p>\r
1460 <tt>title</tt> – the window&#8217;s title has changed\r
1461 </p>\r
1462 </li>\r
1463 <li>\r
1464 <p>\r
1465 <tt>fullscreen_mode</tt> – the window has entered or exited fullscreen mode\r
1466 </p>\r
1467 </li>\r
1468 <li>\r
1469 <p>\r
1470 <tt>move</tt> – the window has changed its position in the tree\r
1471 </p>\r
1472 </li>\r
1473 <li>\r
1474 <p>\r
1475 <tt>floating</tt> – the window has transitioned to or from floating\r
1476 </p>\r
1477 </li>\r
1478 <li>\r
1479 <p>\r
1480 <tt>urgent</tt> – the window has become urgent or lost its urgent status\r
1481 </p>\r
1482 </li>\r
1483 <li>\r
1484 <p>\r
1485 <tt>mark</tt> – a mark has been added to or removed from the window\r
1486 </p>\r
1487 </li>\r
1488 </ul></div>\r
1489 <div class="paragraph"><p>Additionally a <tt>container (object)</tt> field will be present, which consists\r
1490 of the window&#8217;s parent container. Be aware that for the "new" event, the\r
1491 container will hold the initial name of the newly reparented window (e.g.\r
1492 if you run urxvt with a shell that changes the title, you will still at\r
1493 this point get the window title as "urxvt").</p></div>\r
1494 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1495 <div class="listingblock">\r
1496 <div class="content">\r
1497 <pre><tt>{\r
1498  "change": "new",\r
1499  "container": {\r
1500   "id": 35569536,\r
1501   "type": "con",\r
1502   ...\r
1503  }\r
1504 }</tt></pre>\r
1505 </div></div>\r
1506 </div>\r
1507 <div class="sect2">\r
1508 <h3 id="_barconfig_update_event">4.7. barconfig_update event</h3>\r
1509 <div class="paragraph"><p>This event consists of a single serialized map reporting on options from the\r
1510 barconfig of the specified bar_id that were updated in i3. This event is the\r
1511 same as a <tt>GET_BAR_CONFIG</tt> reply for the bar with the given id.</p></div>\r
1512 </div>\r
1513 <div class="sect2">\r
1514 <h3 id="_binding_event">4.8. binding event</h3>\r
1515 <div class="paragraph"><p>This event consists of a single serialized map reporting on the details of a\r
1516 binding that ran a command because of user input. The <tt>change (string)</tt> field\r
1517 indicates what sort of binding event was triggered (right now it will always be\r
1518 <tt>"run"</tt> but may be expanded in the future).</p></div>\r
1519 <div class="paragraph"><p>The <tt>binding (object)</tt> field contains details about the binding that was run:</p></div>\r
1520 <div class="dlist"><dl>\r
1521 <dt class="hdlist1">\r
1522 command (string)\r
1523 </dt>\r
1524 <dd>\r
1525 <p>\r
1526         The i3 command that is configured to run for this binding.\r
1527 </p>\r
1528 </dd>\r
1529 <dt class="hdlist1">\r
1530 event_state_mask (array of strings)\r
1531 </dt>\r
1532 <dd>\r
1533 <p>\r
1534         The group and modifier keys that were configured with this binding.\r
1535 </p>\r
1536 </dd>\r
1537 <dt class="hdlist1">\r
1538 input_code (integer)\r
1539 </dt>\r
1540 <dd>\r
1541 <p>\r
1542         If the binding was configured with <tt>bindcode</tt>, this will be the key code\r
1543         that was given for the binding. If the binding is a mouse binding, it will be\r
1544         the number of the mouse button that was pressed. Otherwise it will be 0.\r
1545 </p>\r
1546 </dd>\r
1547 <dt class="hdlist1">\r
1548 symbol (string or null)\r
1549 </dt>\r
1550 <dd>\r
1551 <p>\r
1552         If this is a keyboard binding that was configured with <tt>bindsym</tt>, this\r
1553         field will contain the given symbol. Otherwise it will be <tt>null</tt>.\r
1554 </p>\r
1555 </dd>\r
1556 <dt class="hdlist1">\r
1557 input_type (string)\r
1558 </dt>\r
1559 <dd>\r
1560 <p>\r
1561         This will be <tt>"keyboard"</tt> or <tt>"mouse"</tt> depending on whether or not this was\r
1562         a keyboard or a mouse binding.\r
1563 </p>\r
1564 </dd>\r
1565 </dl></div>\r
1566 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1567 <div class="listingblock">\r
1568 <div class="content">\r
1569 <pre><tt>{\r
1570  "change": "run",\r
1571  "binding": {\r
1572   "command": "nop",\r
1573   "event_state_mask": [\r
1574     "shift",\r
1575     "ctrl"\r
1576   ],\r
1577   "input_code": 0,\r
1578   "symbol": "t",\r
1579   "input_type": "keyboard"\r
1580  }\r
1581 }</tt></pre>\r
1582 </div></div>\r
1583 </div>\r
1584 <div class="sect2">\r
1585 <h3 id="_shutdown_event">4.9. shutdown event</h3>\r
1586 <div class="paragraph"><p>This event is triggered when the connection to the ipc is about to shutdown\r
1587 because of a user action such as a <tt>restart</tt> or <tt>exit</tt> command. The <tt>change\r
1588 (string)</tt> field indicates why the ipc is shutting down. It can be either\r
1589 <tt>"restart"</tt> or <tt>"exit"</tt>.</p></div>\r
1590 <div class="paragraph"><p><strong>Example:</strong></p></div>\r
1591 <div class="listingblock">\r
1592 <div class="content">\r
1593 <pre><tt>{\r
1594  "change": "restart"\r
1595 }</tt></pre>\r
1596 </div></div>\r
1597 </div>\r
1598 <div class="sect2">\r
1599 <h3 id="_tick_event">4.10. tick event</h3>\r
1600 <div class="paragraph"><p>This event is triggered by a subscription to tick events or by a <tt>SEND_TICK</tt>\r
1601 message.</p></div>\r
1602 <div class="paragraph"><p><strong>Example (upon subscription):</strong></p></div>\r
1603 <div class="listingblock">\r
1604 <div class="content">\r
1605 <pre><tt>{\r
1606  "first": true,\r
1607  "payload": ""\r
1608 }</tt></pre>\r
1609 </div></div>\r
1610 <div class="paragraph"><p><strong>Example (upon <tt>SEND_TICK</tt> with a payload of <tt>arbitrary string</tt>):</strong></p></div>\r
1611 <div class="listingblock">\r
1612 <div class="content">\r
1613 <pre><tt>{\r
1614  "first": false,\r
1615  "payload": "arbitrary string"\r
1616 }</tt></pre>\r
1617 </div></div>\r
1618 </div>\r
1619 </div>\r
1620 </div>\r
1621 <div class="sect1">\r
1622 <h2 id="_see_also_existing_libraries">5. See also (existing libraries)</h2>\r
1623 <div class="sectionbody">\r
1624 <div class="paragraph" id="libraries"><p>For some languages, libraries are available (so you don’t have to implement\r
1625 all this on your own). This list names some (if you wrote one, please let me\r
1626 know):</p></div>\r
1627 <div class="dlist"><dl>\r
1628 <dt class="hdlist1">\r
1629 C\r
1630 </dt>\r
1631 <dd>\r
1632 <div class="ulist"><ul>\r
1633 <li>\r
1634 <p>\r
1635 i3 includes a headerfile <tt>i3/ipc.h</tt> which provides you all constants.\r
1636 </p>\r
1637 </li>\r
1638 <li>\r
1639 <p>\r
1640 <a href="https://github.com/acrisci/i3ipc-glib">https://github.com/acrisci/i3ipc-glib</a>\r
1641 </p>\r
1642 </li>\r
1643 </ul></div>\r
1644 </dd>\r
1645 <dt class="hdlist1">\r
1646 C++\r
1647 </dt>\r
1648 <dd>\r
1649 <div class="ulist"><ul>\r
1650 <li>\r
1651 <p>\r
1652 <a href="https://github.com/drmgc/i3ipcpp">https://github.com/drmgc/i3ipcpp</a>\r
1653 </p>\r
1654 </li>\r
1655 </ul></div>\r
1656 </dd>\r
1657 <dt class="hdlist1">\r
1658 Go\r
1659 </dt>\r
1660 <dd>\r
1661 <div class="ulist"><ul>\r
1662 <li>\r
1663 <p>\r
1664 <a href="https://github.com/mdirkse/i3ipc-go">https://github.com/mdirkse/i3ipc-go</a>\r
1665 </p>\r
1666 </li>\r
1667 <li>\r
1668 <p>\r
1669 <a href="https://github.com/i3/go-i3">https://github.com/i3/go-i3</a>\r
1670 </p>\r
1671 </li>\r
1672 </ul></div>\r
1673 </dd>\r
1674 <dt class="hdlist1">\r
1675 JavaScript\r
1676 </dt>\r
1677 <dd>\r
1678 <div class="ulist"><ul>\r
1679 <li>\r
1680 <p>\r
1681 <a href="https://github.com/acrisci/i3ipc-gjs">https://github.com/acrisci/i3ipc-gjs</a>\r
1682 </p>\r
1683 </li>\r
1684 </ul></div>\r
1685 </dd>\r
1686 <dt class="hdlist1">\r
1687 Lua\r
1688 </dt>\r
1689 <dd>\r
1690 <div class="ulist"><ul>\r
1691 <li>\r
1692 <p>\r
1693 <a href="https://github.com/acrisci/i3ipc-lua">https://github.com/acrisci/i3ipc-lua</a>\r
1694 </p>\r
1695 </li>\r
1696 </ul></div>\r
1697 </dd>\r
1698 <dt class="hdlist1">\r
1699 Perl\r
1700 </dt>\r
1701 <dd>\r
1702 <div class="ulist"><ul>\r
1703 <li>\r
1704 <p>\r
1705 <a href="https://metacpan.org/module/AnyEvent::I3">https://metacpan.org/module/AnyEvent::I3</a>\r
1706 </p>\r
1707 </li>\r
1708 </ul></div>\r
1709 </dd>\r
1710 <dt class="hdlist1">\r
1711 Python\r
1712 </dt>\r
1713 <dd>\r
1714 <div class="ulist"><ul>\r
1715 <li>\r
1716 <p>\r
1717 <a href="https://github.com/acrisci/i3ipc-python">https://github.com/acrisci/i3ipc-python</a>\r
1718 </p>\r
1719 </li>\r
1720 <li>\r
1721 <p>\r
1722 <a href="https://github.com/whitelynx/i3ipc">https://github.com/whitelynx/i3ipc</a> (not maintained)\r
1723 </p>\r
1724 </li>\r
1725 <li>\r
1726 <p>\r
1727 <a href="https://github.com/ziberna/i3-py">https://github.com/ziberna/i3-py</a> (not maintained)\r
1728 </p>\r
1729 </li>\r
1730 </ul></div>\r
1731 </dd>\r
1732 <dt class="hdlist1">\r
1733 Ruby\r
1734 </dt>\r
1735 <dd>\r
1736 <div class="ulist"><ul>\r
1737 <li>\r
1738 <p>\r
1739 <a href="https://github.com/veelenga/i3ipc-ruby">https://github.com/veelenga/i3ipc-ruby</a>\r
1740 </p>\r
1741 </li>\r
1742 <li>\r
1743 <p>\r
1744 <a href="https://github.com/badboy/i3-ipc">https://github.com/badboy/i3-ipc</a> (not maintained)\r
1745 </p>\r
1746 </li>\r
1747 </ul></div>\r
1748 </dd>\r
1749 <dt class="hdlist1">\r
1750 Rust\r
1751 </dt>\r
1752 <dd>\r
1753 <div class="ulist"><ul>\r
1754 <li>\r
1755 <p>\r
1756 <a href="https://github.com/tmerr/i3ipc-rs">https://github.com/tmerr/i3ipc-rs</a>\r
1757 </p>\r
1758 </li>\r
1759 </ul></div>\r
1760 </dd>\r
1761 <dt class="hdlist1">\r
1762 OCaml\r
1763 </dt>\r
1764 <dd>\r
1765 <div class="ulist"><ul>\r
1766 <li>\r
1767 <p>\r
1768 <a href="https://github.com/Armael/ocaml-i3ipc">https://github.com/Armael/ocaml-i3ipc</a>\r
1769 </p>\r
1770 </li>\r
1771 </ul></div>\r
1772 </dd>\r
1773 </dl></div>\r
1774 </div>\r
1775 </div>\r
1776 <div class="sect1">\r
1777 <h2 id="_appendix_a_detecting_byte_order_in_memory_safe_languages">6. Appendix A: Detecting byte order in memory-safe languages</h2>\r
1778 <div class="sectionbody">\r
1779 <div class="paragraph"><p>Some programming languages such as Go don’t offer a way to serialize data in the\r
1780 native byte order of the machine they’re running on without resorting to tricks\r
1781 involving the <tt>unsafe</tt> package.</p></div>\r
1782 <div class="paragraph"><p>The following technique can be used (and will not be broken by changes to i3) to\r
1783 detect the byte order i3 is using:</p></div>\r
1784 <div class="olist arabic"><ol class="arabic">\r
1785 <li>\r
1786 <p>\r
1787 The byte order dependent fields of an IPC message are message type and\r
1788    payload length.\r
1789 </p>\r
1790 <div class="ulist"><ul>\r
1791 <li>\r
1792 <p>\r
1793 The message type <tt>RUN_COMMAND</tt> (0) is the same in big and little endian, so\r
1794      we can use it in either byte order to elicit a reply from i3.\r
1795 </p>\r
1796 </li>\r
1797 <li>\r
1798 <p>\r
1799 The payload length 65536 + 256 (<tt>0x00 01 01 00</tt>) is the same in big and\r
1800      little endian, and also small enough to not worry about memory allocations\r
1801      of that size. We must use payloads of length 65536 + 256 in every message\r
1802      we send, so that i3 will be able to read the entire message regardless of\r
1803      the byte order it uses.\r
1804 </p>\r
1805 </li>\r
1806 </ul></div>\r
1807 </li>\r
1808 <li>\r
1809 <p>\r
1810 Send a big endian encoded message of type <tt>SUBSCRIBE</tt> (2) with payload <tt>[]</tt>\r
1811    followed by 65536 + 256 - 2 <tt>SPACE</tt> (ASCII 0x20) bytes.\r
1812 </p>\r
1813 <div class="ulist"><ul>\r
1814 <li>\r
1815 <p>\r
1816 If i3 is running in big endian, this message is treated as a noop,\r
1817      resulting in a <tt>SUBSCRIBE</tt> reply with payload <tt>{"success":true}</tt>\r
1818      <span class="footnote"><br />[A small payload is important: that way, we circumvent dealing\r
1819      with UNIX domain socket buffer sizes, whose size depends on the\r
1820      implementation/operating system. Exhausting such a buffer results in an i3\r
1821      deadlock unless you concurrently read and write, which — depending on the\r
1822      programming language — makes the technique much more complicated.]<br /></span>.\r
1823 </p>\r
1824 </li>\r
1825 <li>\r
1826 <p>\r
1827 If i3 is running in little endian, this message is read in its entirety due\r
1828      to the byte order independent payload length, then\r
1829      <a href="https://github.com/i3/i3/blob/d726d09d496577d1c337a4b97486f2c9fbc914f1/src/ipc.c#L1188">silently\r
1830      discarded</a> due to the unknown message type.\r
1831 </p>\r
1832 </li>\r
1833 </ul></div>\r
1834 </li>\r
1835 <li>\r
1836 <p>\r
1837 Send a byte order independent message, i.e. type <tt>RUN_COMMAND</tt> (0) with\r
1838    payload <tt>nop byte order detection. padding:</tt>, padded to 65536 + 256 bytes\r
1839    with <tt>a</tt> (ASCII 0x61) bytes. i3 will reply to this message with a reply of\r
1840    type <tt>COMMAND</tt> (0).\r
1841 </p>\r
1842 <div class="ulist"><ul>\r
1843 <li>\r
1844 <p>\r
1845 The human-readable prefix is in there to not confuse readers of the i3 log.\r
1846 </p>\r
1847 </li>\r
1848 <li>\r
1849 <p>\r
1850 This messages serves as a synchronization primitive so that we know whether\r
1851      i3 discarded the <tt>SUBSCRIBE</tt> message or didn’t answer it yet.\r
1852 </p>\r
1853 </li>\r
1854 </ul></div>\r
1855 </li>\r
1856 <li>\r
1857 <p>\r
1858 Receive a message header from i3, decoding the message type as big endian.\r
1859 </p>\r
1860 <div class="ulist"><ul>\r
1861 <li>\r
1862 <p>\r
1863 If the message’s reply type is <tt>COMMAND</tt> (0), i3 is running in little\r
1864      endian (because the <tt>SUBSCRIBE</tt> message was discarded). Decode the message\r
1865      payload length as little endian, receive the message payload.\r
1866 </p>\r
1867 </li>\r
1868 <li>\r
1869 <p>\r
1870 If the message’s reply type is anything else, i3 is running in big endian\r
1871      (because our big endian encoded <tt>SUBSCRIBE</tt> message was answered). Decode\r
1872      the message payload length in big endian, receive the message\r
1873      payload. Then, receive the pending <tt>COMMAND</tt> message reply in big endian.\r
1874 </p>\r
1875 </li>\r
1876 </ul></div>\r
1877 </li>\r
1878 <li>\r
1879 <p>\r
1880 From here on out, send/receive all messages using the detected byte order.\r
1881 </p>\r
1882 </li>\r
1883 </ol></div>\r
1884 <div class="paragraph"><p>Find an example implementation of this technique in\r
1885 <a href="https://github.com/i3/go-i3/blob/master/byteorder.go">https://github.com/i3/go-i3/blob/master/byteorder.go</a></p></div>\r
1886 </div>\r
1887 </div>\r
1888 </div>\r
1889 <div id="footnotes"><hr /></div>\r
1890 <div id="footer" lang="de">\r
1891     © 2009-present Michael Stapelberg,\r
1892     <a href="/impress.html">Impressum</a>,\r
1893     <a href="https://github.com/i3/i3.github.io">Source</a>\r
1894 </div>\r
1895 </body>\r
1896 </html>\r