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
5 <link rel="icon" type="image/png" href="/favicon.png">
\r
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
\r
7 <meta name="generator" content="AsciiDoc 8.6.7" />
\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
13 window.onload = function(){asciidoc.footnotes(); asciidoc.toc(2);}
\r
16 <script type="text/javascript" src="/js/asciidoc-xhtml11.js"></script>
\r
18 <body class="article">
\r
21 <a href="/"><h1 id="title">i3 - improved tiling WM</h1></a>
\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="/contact">Contact</a></li>
\r
26 <li><a href="http://bugs.i3wm.org/">Bugs</a></li>
\r
28 <br style="clear: both">
\r
31 <h1>IPC interface (interprocess communication)</h1>
\r
32 <span id="author">Michael Stapelberg</span><br />
\r
33 <span id="email"><tt><<a href="mailto:michael@i3wm.org">michael@i3wm.org</a>></tt></span><br />
\r
34 <span id="revdate">October 2012</span>
\r
36 <div id="toctitle">Table of Contents</div>
37 <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
41 <div class="sectionbody">
\r
42 <div class="paragraph"><p>This document describes how to interface with i3 from a separate process. This
\r
43 is useful for example to remote-control i3 (to write test cases for example) or
\r
44 to get various information like the current workspaces to implement an external
\r
45 workspace bar.</p></div>
\r
46 <div class="paragraph"><p>The method of choice for IPC in our case is a unix socket because it has very
\r
47 little overhead on both sides and is usually available without headaches in
\r
48 most languages. In the default configuration file, the ipc-socket gets created
\r
49 in <tt>/tmp/i3-%u.XXXXXX/ipc-socket.%p</tt> where <tt>%u</tt> is your UNIX username, <tt>%p</tt> is
\r
50 the PID of i3 and XXXXXX is a string of random characters from the portable
\r
51 filename character set (see mkdtemp(3)). You can get the socketpath from i3 by
\r
52 calling <tt>i3 --get-socketpath</tt>.</p></div>
\r
53 <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
54 X11 property, stored on the X11 root window.</p></div>
\r
55 <div class="admonitionblock">
\r
58 <div class="title">Warning</div>
\r
60 <td class="content">
\r
61 <div class="title">Use an existing library!</div>There are existing libraries for many languages. You can have a look at
\r
62 <a href="#libraries">[libraries]</a> or search the web if your language of choice is not mentioned.
\r
63 Usually, it is not necessary to implement low-level communication with i3
\r
70 <h2 id="_establishing_a_connection">1. Establishing a connection</h2>
\r
71 <div class="sectionbody">
\r
72 <div class="paragraph"><p>To establish a connection, simply open the IPC socket. The following code
\r
73 snippet illustrates this in Perl:</p></div>
\r
74 <div class="listingblock">
\r
75 <div class="content">
\r
76 <pre><tt>use IO::Socket::UNIX;
\r
77 chomp(my $path = qx(i3 --get-socketpath));
\r
78 my $sock = IO::Socket::UNIX->new(Peer => $path);</tt></pre>
\r
83 <h2 id="_sending_messages_to_i3">2. Sending messages to i3</h2>
\r
84 <div class="sectionbody">
\r
85 <div class="paragraph"><p>To send a message to i3, you have to format in the binary message format which
\r
86 i3 expects. This format specifies a magic string in the beginning to ensure
\r
87 the integrity of messages (to prevent follow-up errors). Following the magic
\r
88 string comes the length of the payload of the message as 32-bit integer, and
\r
89 the type of the message as 32-bit integer (the integers are not converted, so
\r
90 they are in native byte order).</p></div>
\r
91 <div class="paragraph"><p>The magic string currently is "i3-ipc" and will only be changed when a change
\r
92 in the IPC API is done which breaks compatibility (we hope that we don’t need
\r
93 to do that).</p></div>
\r
94 <div class="paragraph"><p>Currently implemented message types are the following:</p></div>
\r
95 <div class="dlist"><dl>
\r
96 <dt class="hdlist1">
\r
101 The payload of the message is a command for i3 (like the commands you
\r
102 can bind to keys in the configuration file) and will be executed
\r
103 directly after receiving it.
\r
106 <dt class="hdlist1">
\r
111 Gets the current workspaces. The reply will be a JSON-encoded list of
\r
112 workspaces (see the reply section).
\r
115 <dt class="hdlist1">
\r
120 Subscribes your connection to certain events. See <a href="#events">[events]</a> for a
\r
121 description of this message and the concept of events.
\r
124 <dt class="hdlist1">
\r
129 Gets the current outputs. The reply will be a JSON-encoded list of outputs
\r
130 (see the reply section).
\r
133 <dt class="hdlist1">
\r
138 Gets the layout tree. i3 uses a tree as data structure which includes
\r
139 every container. The reply will be the JSON-encoded tree (see the reply
\r
143 <dt class="hdlist1">
\r
148 Gets a list of marks (identifiers for containers to easily jump to them
\r
149 later). The reply will be a JSON-encoded list of window marks (see
\r
153 <dt class="hdlist1">
\r
158 Gets the configuration (as JSON map) of the workspace bar with the
\r
159 given ID. If no ID is provided, an array with all configured bar IDs is
\r
163 <dt class="hdlist1">
\r
168 Gets the version of i3. The reply will be a JSON-encoded dictionary
\r
169 with the major, minor, patch and human-readable version.
\r
173 <div class="paragraph"><p>So, a typical message could look like this:</p></div>
\r
174 <div class="listingblock">
\r
175 <div class="content">
\r
176 <pre><tt>"i3-ipc" <message length> <message type> <payload></tt></pre>
\r
178 <div class="paragraph"><p>Or, as a hexdump:</p></div>
\r
179 <div class="listingblock">
\r
180 <div class="content">
\r
181 <pre><tt>00000000 69 33 2d 69 70 63 04 00 00 00 00 00 00 00 65 78 |i3-ipc........ex|
\r
182 00000010 69 74 |it|</tt></pre>
\r
184 <div class="paragraph"><p>To generate and send such a message, you could use the following code in Perl:</p></div>
\r
185 <div class="listingblock">
\r
186 <div class="content">
\r
187 <pre><tt>sub format_ipc_command {
\r
190 # Get the real byte count (vs. amount of characters)
\r
191 { use bytes; $len = length($msg); }
\r
192 return "i3-ipc" . pack("LL", $len, 0) . $msg;
\r
195 $sock->write(format_ipc_command("exit"));</tt></pre>
\r
199 <div class="sect1">
\r
200 <h2 id="_receiving_replies_from_i3">3. Receiving replies from i3</h2>
\r
201 <div class="sectionbody">
\r
202 <div class="paragraph"><p>Replies from i3 usually consist of a simple string (the length of the string
\r
203 is the message_length, so you can consider them length-prefixed) which in turn
\r
204 contain the JSON serialization of a data structure. For example, the
\r
205 GET_WORKSPACES message returns an array of workspaces (each workspace is a map
\r
206 with certain attributes).</p></div>
\r
207 <div class="sect2">
\r
208 <h3 id="_reply_format">3.1. Reply format</h3>
\r
209 <div class="paragraph"><p>The reply format is identical to the normal message format. There also is
\r
210 the magic string, then the message length, then the message type and the
\r
212 <div class="paragraph"><p>The following reply types are implemented:</p></div>
\r
213 <div class="dlist"><dl>
\r
214 <dt class="hdlist1">
\r
219 Confirmation/Error code for the COMMAND message.
\r
222 <dt class="hdlist1">
\r
227 Reply to the GET_WORKSPACES message.
\r
230 <dt class="hdlist1">
\r
235 Confirmation/Error code for the SUBSCRIBE message.
\r
238 <dt class="hdlist1">
\r
243 Reply to the GET_OUTPUTS message.
\r
246 <dt class="hdlist1">
\r
251 Reply to the GET_TREE message.
\r
254 <dt class="hdlist1">
\r
259 Reply to the GET_MARKS message.
\r
262 <dt class="hdlist1">
\r
267 Reply to the GET_BAR_CONFIG message.
\r
270 <dt class="hdlist1">
\r
275 Reply to the GET_VERSION message.
\r
280 <div class="sect2">
\r
281 <h3 id="_command_reply">3.2. COMMAND reply</h3>
\r
282 <div class="paragraph"><p>The reply consists of a single serialized map. At the moment, the only
\r
283 property is <tt>success (bool)</tt>, but this will be expanded in future versions.</p></div>
\r
284 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
285 <div class="listingblock">
\r
286 <div class="content">
\r
287 <pre><tt>{ "success": true }</tt></pre>
\r
290 <div class="sect2">
\r
291 <h3 id="_workspaces_reply">3.3. WORKSPACES reply</h3>
\r
292 <div class="paragraph"><p>The reply consists of a serialized list of workspaces. Each workspace has the
\r
293 following properties:</p></div>
\r
294 <div class="dlist"><dl>
\r
295 <dt class="hdlist1">
\r
300 The logical number of the workspace. Corresponds to the command
\r
301 to switch to this workspace.
\r
304 <dt class="hdlist1">
\r
309 The name of this workspace (by default num+1), as changed by the
\r
310 user. Encoded in UTF-8.
\r
313 <dt class="hdlist1">
\r
318 Whether this workspace is currently visible on an output (multiple
\r
319 workspaces can be visible at the same time).
\r
322 <dt class="hdlist1">
\r
327 Whether this workspace currently has the focus (only one workspace
\r
328 can have the focus at the same time).
\r
331 <dt class="hdlist1">
\r
336 Whether a window on this workspace has the "urgent" flag set.
\r
339 <dt class="hdlist1">
\r
344 The rectangle of this workspace (equals the rect of the output it
\r
345 is on), consists of x, y, width, height.
\r
348 <dt class="hdlist1">
\r
353 The video output this workspace is on (LVDS1, VGA1, …).
\r
357 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
358 <div class="listingblock">
\r
359 <div class="content">
\r
392 <div class="sect2">
\r
393 <h3 id="_subscribe_reply">3.4. SUBSCRIBE reply</h3>
\r
394 <div class="paragraph"><p>The reply consists of a single serialized map. The only property is
\r
395 <tt>success (bool)</tt>, indicating whether the subscription was successful (the
\r
396 default) or whether a JSON parse error occurred.</p></div>
\r
397 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
398 <div class="listingblock">
\r
399 <div class="content">
\r
400 <pre><tt>{ "success": true }</tt></pre>
\r
403 <div class="sect2">
\r
404 <h3 id="_outputs_reply">3.5. OUTPUTS reply</h3>
\r
405 <div class="paragraph"><p>The reply consists of a serialized list of outputs. Each output has the
\r
406 following properties:</p></div>
\r
407 <div class="dlist"><dl>
\r
408 <dt class="hdlist1">
\r
413 The name of this output (as seen in <tt>xrandr(1)</tt>). Encoded in UTF-8.
\r
416 <dt class="hdlist1">
\r
421 Whether this output is currently active (has a valid mode).
\r
424 <dt class="hdlist1">
\r
425 current_workspace (integer)
\r
429 The current workspace which is visible on this output. <tt>null</tt> if the
\r
430 output is not active.
\r
433 <dt class="hdlist1">
\r
438 The rectangle of this output (equals the rect of the output it
\r
439 is on), consists of x, y, width, height.
\r
443 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
444 <div class="listingblock">
\r
445 <div class="content">
\r
450 "current_workspace": 4,
\r
461 "current_workspace": 1,
\r
472 <div class="sect2">
\r
473 <h3 id="_tree_reply">3.6. TREE reply</h3>
\r
474 <div class="paragraph"><p>The reply consists of a serialized tree. Each node in the tree (representing
\r
475 one container) has at least the properties listed below. While the nodes might
\r
476 have more properties, please do not use any properties which are not documented
\r
477 here. They are not yet finalized and will probably change!</p></div>
\r
478 <div class="dlist"><dl>
\r
479 <dt class="hdlist1">
\r
484 The internal ID (actually a C pointer value) of this container. Do not
\r
485 make any assumptions about it. You can use it to (re-)identify and
\r
486 address containers when talking to i3.
\r
489 <dt class="hdlist1">
\r
494 The internal name of this container. For all containers which are part
\r
495 of the tree structure down to the workspace contents, this is set to a
\r
496 nice human-readable name of the container.
\r
497 For all other containers, the content is not defined (yet).
\r
500 <dt class="hdlist1">
\r
505 Can be either "normal", "none" or "1pixel", dependending on the
\r
506 container’s border style.
\r
509 <dt class="hdlist1">
\r
510 current_border_width (integer)
\r
514 Number of pixels of the border width.
\r
517 <dt class="hdlist1">
\r
522 Can be either "splith", "splitv", "stacked", "tabbed", "dockarea" or
\r
524 Other values might be possible in the future, should we add new
\r
528 <dt class="hdlist1">
\r
529 orientation (string)
\r
533 Can be either "none" (for non-split containers), "horizontal" or
\r
535 THIS FIELD IS OBSOLETE. It is still present, but your code should not
\r
536 use it. Instead, rely on the layout field.
\r
539 <dt class="hdlist1">
\r
544 The percentage which this container takes in its parent. A value of
\r
545 <tt>null</tt> means that the percent property does not make sense for this
\r
546 container, for example for the root container.
\r
549 <dt class="hdlist1">
\r
554 The absolute display coordinates for this container. Display
\r
555 coordinates means that when you have two 1600x1200 monitors on a single
\r
556 X11 Display (the standard way), the coordinates of the first window on
\r
557 the second monitor are <tt>{ "x": 1600, "y": 0, "width": 1600, "height":
\r
561 <dt class="hdlist1">
\r
566 The coordinates of the <strong>actual client window</strong> inside its container.
\r
567 These coordinates are relative to the container and do not include the
\r
568 window decoration (which is actually rendered on the parent container).
\r
569 So, when using the <tt>default</tt> layout, you will have a 2 pixel border on
\r
570 each side, making the window_rect <tt>{ "x": 2, "y": 0, "width": 632,
\r
571 "height": 366 }</tt> (for example).
\r
574 <dt class="hdlist1">
\r
579 The original geometry the window specified when i3 mapped it. Used when
\r
580 switching a window to floating mode, for example.
\r
583 <dt class="hdlist1">
\r
588 The X11 window ID of the <strong>actual client window</strong> inside this container.
\r
589 This field is set to null for split containers or otherwise empty
\r
590 containers. This ID corresponds to what xwininfo(1) and other
\r
591 X11-related tools display (usually in hex).
\r
594 <dt class="hdlist1">
\r
599 Whether this container (window or workspace) has the urgency hint set.
\r
602 <dt class="hdlist1">
\r
607 Whether this container is currently focused.
\r
611 <div class="paragraph"><p>Please note that in the following example, I have left out some keys/values
\r
612 which are not relevant for the type of the node. Otherwise, the example would
\r
613 be by far too long (it already is quite long, despite showing only 1 window and
\r
614 one dock window).</p></div>
\r
615 <div class="paragraph"><p>It is useful to have an overview of the structure before taking a look at the
\r
616 JSON dump:</p></div>
\r
617 <div class="ulist"><ul>
\r
622 <div class="ulist"><ul>
\r
627 <div class="ulist"><ul>
\r
637 <div class="ulist"><ul>
\r
642 <div class="ulist"><ul>
\r
656 <div class="ulist"><ul>
\r
674 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
675 <div class="listingblock">
\r
676 <div class="content">
\r
691 "layout": "output",
\r
703 "layout": "dockarea",
\r
704 "orientation": "vertical",
\r
727 "orientation": "horizontal",
\r
734 "floating_nodes": [],
\r
740 "border": "normal",
\r
758 "name": "bottomdock",
\r
759 "layout": "dockarea",
\r
760 "orientation": "vertical",
\r
789 <div class="sect2">
\r
790 <h3 id="_marks_reply">3.7. MARKS reply</h3>
\r
791 <div class="paragraph"><p>The reply consists of a single array of strings for each container that has a
\r
792 mark. A mark can only be set on one container, so the array is unique.
\r
793 The order of that array is undefined.</p></div>
\r
794 <div class="paragraph"><p>If no window has a mark the response will be the empty array [].</p></div>
\r
796 <div class="sect2">
\r
797 <h3 id="_bar_config_reply">3.8. BAR_CONFIG reply</h3>
\r
798 <div class="paragraph"><p>This can be used by third-party workspace bars (especially i3bar, but others
\r
799 are free to implement compatible alternatives) to get the <tt>bar</tt> block
\r
800 configuration from i3.</p></div>
\r
801 <div class="paragraph"><p>Depending on the input, the reply is either:</p></div>
\r
802 <div class="dlist"><dl>
\r
803 <dt class="hdlist1">
\r
808 An array of configured bar IDs
\r
811 <dt class="hdlist1">
\r
816 A JSON map containing the configuration for the specified bar.
\r
820 <div class="paragraph"><p>Each bar configuration has the following properties:</p></div>
\r
821 <div class="dlist"><dl>
\r
822 <dt class="hdlist1">
\r
827 The ID for this bar. Included in case you request multiple
\r
828 configurations and want to differentiate the different replies.
\r
831 <dt class="hdlist1">
\r
836 Either <tt>dock</tt> (the bar sets the dock window type) or <tt>hide</tt> (the bar
\r
837 does not show unless a specific key is pressed).
\r
840 <dt class="hdlist1">
\r
845 Either <tt>bottom</tt> or <tt>top</tt> at the moment.
\r
848 <dt class="hdlist1">
\r
849 status_command (string)
\r
853 Command which will be run to generate a statusline. Each line on stdout
\r
854 of this command will be displayed in the bar. At the moment, no
\r
855 formatting is supported.
\r
858 <dt class="hdlist1">
\r
863 The font to use for text on the bar.
\r
866 <dt class="hdlist1">
\r
867 workspace_buttons (boolean)
\r
871 Display workspace buttons or not? Defaults to true.
\r
874 <dt class="hdlist1">
\r
879 Should the bar enable verbose output for debugging? Defaults to false.
\r
882 <dt class="hdlist1">
\r
887 Contains key/value pairs of colors. Each value is a color code in hex,
\r
888 formatted #rrggbb (like in HTML).
\r
892 <div class="paragraph"><p>The following colors can be configured at the moment:</p></div>
\r
893 <div class="dlist"><dl>
\r
894 <dt class="hdlist1">
\r
899 Background color of the bar.
\r
902 <dt class="hdlist1">
\r
907 Text color to be used for the statusline.
\r
910 <dt class="hdlist1">
\r
915 Text color to be used for the separator.
\r
918 <dt class="hdlist1">
\r
919 focused_workspace_text/focused_workspace_bg
\r
923 Text color/background color for a workspace button when the workspace
\r
927 <dt class="hdlist1">
\r
928 active_workspace_text/active_workspace_bg
\r
932 Text color/background color for a workspace button when the workspace
\r
933 is active (visible) on some output, but the focus is on another one.
\r
934 You can only tell this apart from the focused workspace when you are
\r
935 using multiple monitors.
\r
938 <dt class="hdlist1">
\r
939 inactive_workspace_text/inactive_workspace_bg
\r
943 Text color/background color for a workspace button when the workspace
\r
944 does not have focus and is not active (visible) on any output. This
\r
945 will be the case for most workspaces.
\r
948 <dt class="hdlist1">
\r
949 urgent_workspace_text/urgent_workspace_bar
\r
953 Text color/background color for workspaces which contain at least one
\r
954 window with the urgency hint set.
\r
958 <div class="paragraph"><p><strong>Example of configured bars:</strong></p></div>
\r
959 <div class="listingblock">
\r
960 <div class="content">
\r
961 <pre><tt>["bar-bxuqzf"]</tt></pre>
\r
963 <div class="paragraph"><p><strong>Example of bar configuration:</strong></p></div>
\r
964 <div class="listingblock">
\r
965 <div class="content">
\r
967 "id": "bar-bxuqzf",
\r
969 "position": "bottom",
\r
970 "status_command": "i3status",
\r
971 "font": "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1",
\r
972 "workspace_buttons": true,
\r
975 "background": "#c0c0c0",
\r
976 "statusline": "#00ff00",
\r
977 "focused_workspace_text": "#ffffff",
\r
978 "focused_workspace_bg": "#000000"
\r
983 <div class="sect2">
\r
984 <h3 id="_version_reply">3.9. VERSION reply</h3>
\r
985 <div class="paragraph"><p>The reply consists of a single JSON dictionary with the following keys:</p></div>
\r
986 <div class="dlist"><dl>
\r
987 <dt class="hdlist1">
\r
992 The major version of i3, such as <tt>4</tt>.
\r
995 <dt class="hdlist1">
\r
1000 The minor version of i3, such as <tt>2</tt>. Changes in the IPC interface (new
\r
1001 features) will only occur with new minor (or major) releases. However,
\r
1002 bugfixes might be introduced in patch releases, too.
\r
1005 <dt class="hdlist1">
\r
1010 The patch version of i3, such as <tt>1</tt> (when the complete version is
\r
1011 <tt>4.2.1</tt>). For versions such as <tt>4.2</tt>, patch will be set to <tt>0</tt>.
\r
1014 <dt class="hdlist1">
\r
1015 human_readable (string)
\r
1019 A human-readable version of i3 containing the precise git version,
\r
1020 build date and branch name. When you need to display the i3 version to
\r
1021 your users, use the human-readable version whenever possible (since
\r
1022 this is what <tt>i3 --version</tt> displays, too).
\r
1026 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1027 <div class="listingblock">
\r
1028 <div class="content">
\r
1030 "human_readable" : "4.2-169-gf80b877 (2012-08-05, branch \"next\")",
\r
1039 <div class="sect1">
\r
1040 <h2 id="_events">4. Events</h2>
\r
1041 <div class="sectionbody">
\r
1042 <div class="paragraph" id="events"><p>To get informed when certain things happen in i3, clients can subscribe to
\r
1043 events. Events consist of a name (like "workspace") and an event reply type
\r
1044 (like I3_IPC_EVENT_WORKSPACE). The events sent by i3 are in the same format
\r
1045 as replies to specific commands. However, the highest bit of the message type
\r
1046 is set to 1 to indicate that this is an event reply instead of a normal reply.</p></div>
\r
1047 <div class="paragraph"><p>Caveat: As soon as you subscribe to an event, it is not guaranteed any longer
\r
1048 that the requests to i3 are processed in order. This means, the following
\r
1049 situation can happen: You send a GET_WORKSPACES request but you receive a
\r
1050 "workspace" event before receiving the reply to GET_WORKSPACES. If your
\r
1051 program does not want to cope which such kinds of race conditions (an
\r
1052 event based library may not have a problem here), I suggest you create a
\r
1053 separate connection to receive events.</p></div>
\r
1054 <div class="sect2">
\r
1055 <h3 id="_subscribing_to_events">4.1. Subscribing to events</h3>
\r
1056 <div class="paragraph"><p>By sending a message of type SUBSCRIBE with a JSON-encoded array as payload
\r
1057 you can register to an event.</p></div>
\r
1058 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1059 <div class="listingblock">
\r
1060 <div class="content">
\r
1061 <pre><tt>type: SUBSCRIBE
\r
1062 payload: [ "workspace", "focus" ]</tt></pre>
\r
1065 <div class="sect2">
\r
1066 <h3 id="_available_events">4.2. Available events</h3>
\r
1067 <div class="paragraph"><p>The numbers in parenthesis is the event type (keep in mind that you need to
\r
1068 strip the highest bit first).</p></div>
\r
1069 <div class="dlist"><dl>
\r
1070 <dt class="hdlist1">
\r
1075 Sent when the user switches to a different workspace, when a new
\r
1076 workspace is initialized or when a workspace is removed (because the
\r
1077 last client vanished).
\r
1080 <dt class="hdlist1">
\r
1085 Sent when RandR issues a change notification (of either screens,
\r
1086 outputs, CRTCs or output properties).
\r
1089 <dt class="hdlist1">
\r
1094 Sent whenever i3 changes its binding mode.
\r
1097 <dt class="hdlist1">
\r
1102 Sent when a client’s window is successfully reparented (that is when i3
\r
1103 has finished fitting it into a container).
\r
1106 <dt class="hdlist1">
\r
1107 barconfig_update (4)
\r
1111 Sent when the hidden_state or mode field in the barconfig of any bar
\r
1112 instance was updated.
\r
1116 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1117 <div class="listingblock">
\r
1118 <div class="content">
\r
1119 <pre><tt># the appropriate 4 bytes read from the socket are stored in $input
\r
1121 # unpack a 32-bit unsigned integer
\r
1122 my $message_type = unpack("L", $input);
\r
1124 # check if the highest bit is 1
\r
1125 my $is_event = (($message_type >> 31) == 1);
\r
1127 # use the other bits
\r
1128 my $event_type = ($message_type & 0x7F);
\r
1131 say "Received event of type $event_type";
\r
1135 <div class="sect2">
\r
1136 <h3 id="_workspace_event">4.3. workspace event</h3>
\r
1137 <div class="paragraph"><p>This event consists of a single serialized map containing a property
\r
1138 <tt>change (string)</tt> which indicates the type of the change ("focus", "init",
\r
1139 "empty", "urgent").</p></div>
\r
1140 <div class="paragraph"><p>Moreover, when the change is "focus", an <tt>old (object)</tt> and a <tt>current
\r
1141 (object)</tt> properties will be present with the previous and current
\r
1142 workspace respectively. When the first switch occurs (when i3 focuses
\r
1143 the workspace visible at the beginning) there is no previous
\r
1144 workspace, and the <tt>old</tt> property will be set to <tt>null</tt>. Also note
\r
1145 that if the previous is empty it will get destroyed when switching,
\r
1146 but will still be present in the "old" property.</p></div>
\r
1147 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1148 <div class="listingblock">
\r
1149 <div class="content">
\r
1151 "change": "focus",
\r
1165 <div class="sect2">
\r
1166 <h3 id="_output_event">4.4. output event</h3>
\r
1167 <div class="paragraph"><p>This event consists of a single serialized map containing a property
\r
1168 <tt>change (string)</tt> which indicates the type of the change (currently only
\r
1169 "unspecified").</p></div>
\r
1170 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1171 <div class="listingblock">
\r
1172 <div class="content">
\r
1173 <pre><tt>{ "change": "unspecified" }</tt></pre>
\r
1176 <div class="sect2">
\r
1177 <h3 id="_mode_event">4.5. mode event</h3>
\r
1178 <div class="paragraph"><p>This event consists of a single serialized map containing a property
\r
1179 <tt>change (string)</tt> which holds the name of current mode in use. The name
\r
1180 is the same as specified in config when creating a mode. The default
\r
1181 mode is simply named default.</p></div>
\r
1182 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1183 <div class="listingblock">
\r
1184 <div class="content">
\r
1185 <pre><tt>{ "change": "default" }</tt></pre>
\r
1188 <div class="sect2">
\r
1189 <h3 id="_window_event">4.6. window event</h3>
\r
1190 <div class="paragraph"><p>This event consists of a single serialized map containing a property
\r
1191 <tt>change (string)</tt> which currently can indicate only that a new window
\r
1192 has been successfully reparented (the value will be "new").</p></div>
\r
1193 <div class="paragraph"><p>Additionally a <tt>container (object)</tt> field will be present, which consists
\r
1194 of the window’s parent container. Be aware that the container will hold
\r
1195 the initial name of the newly reparented window (e.g. if you run urxvt
\r
1196 with a shell that changes the title, you will still at this point get the
\r
1197 window title as "urxvt").</p></div>
\r
1198 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1199 <div class="listingblock">
\r
1200 <div class="content">
\r
1211 <div class="sect2">
\r
1212 <h3 id="_barconfig_update_event">4.7. barconfig_update event</h3>
\r
1213 <div class="paragraph"><p>This event consists of a single serialized map reporting on options from the
\r
1214 barconfig of the specified bar_id that were updated in i3. The map always
\r
1215 consists of a property <tt>id (string)</tt>, which specifies to which bar instance the
\r
1216 sent config update belongs, a property <tt>hidden_state (string)</tt>, which indicates
\r
1217 the hidden_state of an i3bar instance, and a property <tt>mode (string)</tt>, which
\r
1218 corresponds to the current mode.</p></div>
\r
1219 <div class="paragraph"><p><strong>Example:</strong></p></div>
\r
1220 <div class="listingblock">
\r
1221 <div class="content">
\r
1224 "hidden_state": "hide"
\r
1231 <div class="sect1">
\r
1232 <h2 id="_see_also_existing_libraries">5. See also (existing libraries)</h2>
\r
1233 <div class="sectionbody">
\r
1234 <div class="paragraph" id="libraries"><p>For some languages, libraries are available (so you don’t have to implement
\r
1235 all this on your own). This list names some (if you wrote one, please let me
\r
1237 <div class="dlist"><dl>
\r
1238 <dt class="hdlist1">
\r
1243 i3 includes a headerfile <tt>i3/ipc.h</tt> which provides you all constants.
\r
1244 However, there is no library yet.
\r
1247 <dt class="hdlist1">
\r
1252 <a href="http://github.com/badboy/i3-ipc">http://github.com/badboy/i3-ipc</a>
\r
1255 <dt class="hdlist1">
\r
1260 <a href="https://metacpan.org/module/AnyEvent::I3">https://metacpan.org/module/AnyEvent::I3</a>
\r
1263 <dt class="hdlist1">
\r
1267 <div class="ulist"><ul>
\r
1270 <a href="https://github.com/whitelynx/i3ipc">https://github.com/whitelynx/i3ipc</a>
\r
1275 <a href="https://github.com/ziberna/i3-py">https://github.com/ziberna/i3-py</a> (includes higher-level features)
\r
1280 <dt class="hdlist1">
\r
1284 <div class="ulist"><ul>
\r
1287 <a href="https://github.com/proxypoke/i3ipc">https://github.com/proxypoke/i3ipc</a>
\r
1296 <div id="footnotes"><hr /></div>
\r
1297 <div id="footer" lang="de">
\r
1298 © 2009-2011 Michael Stapelberg, <a href="/impress.html">Impressum</a>
\r