File: ipc.html

package info (click to toggle)
i3-wm 4.25-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,676 kB
  • sloc: ansic: 30,144; perl: 19,136; sh: 70; makefile: 9
file content (2963 lines) | stat: -rw-r--r-- 84,403 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 10.2.1" />
<title>IPC interface (interprocess communication)</title>
<style type="text/css">
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */

/* Default font. */
body {
  font-family: Georgia,serif;
}

/* Title font. */
h1, h2, h3, h4, h5, h6,
div.title, caption.title,
thead, p.table.header,
#toctitle,
#author, #revnumber, #revdate, #revremark,
#footer {
  font-family: Arial,Helvetica,sans-serif;
}

body {
  margin: 1em 5% 1em 5%;
}

a {
  color: blue;
  text-decoration: underline;
}
a:visited {
  color: fuchsia;
}

em {
  font-style: italic;
  color: navy;
}

strong {
  font-weight: bold;
  color: #083194;
}

h1, h2, h3, h4, h5, h6 {
  color: #527bbd;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

h1, h2, h3 {
  border-bottom: 2px solid silver;
}
h2 {
  padding-top: 0.5em;
}
h3 {
  float: left;
}
h3 + * {
  clear: left;
}
h5 {
  font-size: 1.0em;
}

div.sectionbody {
  margin-left: 0;
}

hr {
  border: 1px solid silver;
}

p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

ul, ol, li > p {
  margin-top: 0;
}
ul > li     { color: #aaa; }
ul > li > * { color: black; }

.monospaced, code, pre {
  font-family: "Courier New", Courier, monospace;
  font-size: inherit;
  color: navy;
  padding: 0;
  margin: 0;
}
pre {
  white-space: pre-wrap;
}

#author {
  color: #527bbd;
  font-weight: bold;
  font-size: 1.1em;
}
#email {
}
#revnumber, #revdate, #revremark {
}

#footer {
  font-size: small;
  border-top: 2px solid silver;
  padding-top: 0.5em;
  margin-top: 4.0em;
}
#footer-text {
  float: left;
  padding-bottom: 0.5em;
}
#footer-badges {
  float: right;
  padding-bottom: 0.5em;
}

#preamble {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}
div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
div.admonitionblock {
  margin-top: 2.0em;
  margin-bottom: 2.0em;
  margin-right: 10%;
  color: #606060;
}

div.content { /* Block element content. */
  padding: 0;
}

/* Block element titles. */
div.title, caption.title {
  color: #527bbd;
  font-weight: bold;
  text-align: left;
  margin-top: 1.0em;
  margin-bottom: 0.5em;
}
div.title + * {
  margin-top: 0;
}

td div.title:first-child {
  margin-top: 0.0em;
}
div.content div.title:first-child {
  margin-top: 0.0em;
}
div.content + div.title {
  margin-top: 0.0em;
}

div.sidebarblock > div.content {
  background: #ffffee;
  border: 1px solid #dddddd;
  border-left: 4px solid #f0f0f0;
  padding: 0.5em;
}

div.listingblock > div.content {
  border: 1px solid #dddddd;
  border-left: 5px solid #f0f0f0;
  background: #f8f8f8;
  padding: 0.5em;
}

div.quoteblock, div.verseblock {
  padding-left: 1.0em;
  margin-left: 1.0em;
  margin-right: 10%;
  border-left: 5px solid #f0f0f0;
  color: #888;
}

div.quoteblock > div.attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock > pre.content {
  font-family: inherit;
  font-size: inherit;
}
div.verseblock > div.attribution {
  padding-top: 0.75em;
  text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
  text-align: left;
}

div.admonitionblock .icon {
  vertical-align: top;
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: underline;
  color: #527bbd;
  padding-right: 0.5em;
}
div.admonitionblock td.content {
  padding-left: 0.5em;
  border-left: 3px solid #dddddd;
}

div.exampleblock > div.content {
  border-left: 3px solid #dddddd;
  padding-left: 0.5em;
}

div.imageblock div.content { padding-left: 0; }
span.image img { border-style: none; vertical-align: text-bottom; }
a.image:visited { color: white; }

dl {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
dt {
  margin-top: 0.5em;
  margin-bottom: 0;
  font-style: normal;
  color: navy;
}
dd > *:first-child {
  margin-top: 0.1em;
}

ul, ol {
    list-style-position: outside;
}
ol.arabic {
  list-style-type: decimal;
}
ol.loweralpha {
  list-style-type: lower-alpha;
}
ol.upperalpha {
  list-style-type: upper-alpha;
}
ol.lowerroman {
  list-style-type: lower-roman;
}
ol.upperroman {
  list-style-type: upper-roman;
}

div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
}

tfoot {
  font-weight: bold;
}
td > div.verse {
  white-space: pre;
}

div.hdlist {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
div.hdlist tr {
  padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
  font-weight: bold;
}
td.hdlist1 {
  vertical-align: top;
  font-style: normal;
  padding-right: 0.8em;
  color: navy;
}
td.hdlist2 {
  vertical-align: top;
}
div.hdlist.compact tr {
  margin: 0;
  padding-bottom: 0;
}

.comment {
  background: yellow;
}

.footnote, .footnoteref {
  font-size: 0.8em;
}

span.footnote, span.footnoteref {
  vertical-align: super;
}

#footnotes {
  margin: 20px 0 20px 0;
  padding: 7px 0 0 0;
}

#footnotes div.footnote {
  margin: 0 0 5px 0;
}

#footnotes hr {
  border: none;
  border-top: 1px solid silver;
  height: 1px;
  text-align: left;
  margin-left: 0;
  width: 20%;
  min-width: 100px;
}

div.colist td {
  padding-right: 0.5em;
  padding-bottom: 0.3em;
  vertical-align: top;
}
div.colist td img {
  margin-top: 0.3em;
}

@media print {
  #footer-badges { display: none; }
}

#toc {
  margin-bottom: 2.5em;
}

#toctitle {
  color: #527bbd;
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1.0em;
  margin-bottom: 0.1em;
}

div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
  margin-top: 0;
  margin-bottom: 0;
}
div.toclevel2 {
  margin-left: 2em;
  font-size: 0.9em;
}
div.toclevel3 {
  margin-left: 4em;
  font-size: 0.9em;
}
div.toclevel4 {
  margin-left: 6em;
  font-size: 0.9em;
}

span.aqua { color: aqua; }
span.black { color: black; }
span.blue { color: blue; }
span.fuchsia { color: fuchsia; }
span.gray { color: gray; }
span.green { color: green; }
span.lime { color: lime; }
span.maroon { color: maroon; }
span.navy { color: navy; }
span.olive { color: olive; }
span.purple { color: purple; }
span.red { color: red; }
span.silver { color: silver; }
span.teal { color: teal; }
span.white { color: white; }
span.yellow { color: yellow; }

span.aqua-background { background: aqua; }
span.black-background { background: black; }
span.blue-background { background: blue; }
span.fuchsia-background { background: fuchsia; }
span.gray-background { background: gray; }
span.green-background { background: green; }
span.lime-background { background: lime; }
span.maroon-background { background: maroon; }
span.navy-background { background: navy; }
span.olive-background { background: olive; }
span.purple-background { background: purple; }
span.red-background { background: red; }
span.silver-background { background: silver; }
span.teal-background { background: teal; }
span.white-background { background: white; }
span.yellow-background { background: yellow; }

span.big { font-size: 2em; }
span.small { font-size: 0.6em; }

span.underline { text-decoration: underline; }
span.overline { text-decoration: overline; }
span.line-through { text-decoration: line-through; }

div.unbreakable { page-break-inside: avoid; }


/*
 * xhtml11 specific
 *
 * */

div.tableblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
div.tableblock > table {
  border: 3px solid #527bbd;
}
thead, p.table.header {
  font-weight: bold;
  color: #527bbd;
}
p.table {
  margin-top: 0;
}
/* Because the table frame attribute is overridden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
  border-style: none;
}
div.tableblock > table[frame="hsides"] {
  border-left-style: none;
  border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
  border-top-style: none;
  border-bottom-style: none;
}


/*
 * html5 specific
 *
 * */

table.tableblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
thead, p.tableblock.header {
  font-weight: bold;
  color: #527bbd;
}
p.tableblock {
  margin-top: 0;
}
table.tableblock {
  border-width: 3px;
  border-spacing: 0px;
  border-style: solid;
  border-color: #527bbd;
  border-collapse: collapse;
}
th.tableblock, td.tableblock {
  border-width: 1px;
  padding: 4px;
  border-style: solid;
  border-color: #527bbd;
}

table.tableblock.frame-topbot {
  border-left-style: hidden;
  border-right-style: hidden;
}
table.tableblock.frame-sides {
  border-top-style: hidden;
  border-bottom-style: hidden;
}
table.tableblock.frame-none {
  border-style: hidden;
}

th.tableblock.halign-left, td.tableblock.halign-left {
  text-align: left;
}
th.tableblock.halign-center, td.tableblock.halign-center {
  text-align: center;
}
th.tableblock.halign-right, td.tableblock.halign-right {
  text-align: right;
}

th.tableblock.valign-top, td.tableblock.valign-top {
  vertical-align: top;
}
th.tableblock.valign-middle, td.tableblock.valign-middle {
  vertical-align: middle;
}
th.tableblock.valign-bottom, td.tableblock.valign-bottom {
  vertical-align: bottom;
}


/*
 * manpage specific
 *
 * */

body.manpage h1 {
  padding-top: 0.5em;
  padding-bottom: 0.5em;
  border-top: 2px solid silver;
  border-bottom: 2px solid silver;
}
body.manpage h2 {
  border-style: none;
}
body.manpage div.sectionbody {
  margin-left: 3em;
}

@media print {
  body.manpage div#toc { display: none; }
}


</style>
<script type="text/javascript">
/*<![CDATA[*/
var asciidoc = {  // Namespace.

/////////////////////////////////////////////////////////////////////
// Table Of Contents generator
/////////////////////////////////////////////////////////////////////

/* Author: Mihai Bazon, September 2002
 * http://students.infoiasi.ro/~mishoo
 *
 * Table Of Content generator
 * Version: 0.4
 *
 * Feel free to use this script under the terms of the GNU General Public
 * License, as long as you do not remove or alter this notice.
 */

 /* modified by Troy D. Hanson, September 2006. License: GPL */
 /* modified by Stuart Rackham, 2006, 2009. License: GPL */

// toclevels = 1..4.
toc: function (toclevels) {

  function getText(el) {
    var text = "";
    for (var i = el.firstChild; i != null; i = i.nextSibling) {
      if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
        text += i.data;
      else if (i.firstChild != null)
        text += getText(i);
    }
    return text;
  }

  function TocEntry(el, text, toclevel) {
    this.element = el;
    this.text = text;
    this.toclevel = toclevel;
  }

  function tocEntries(el, toclevels) {
    var result = new Array;
    var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
    // Function that scans the DOM tree for header elements (the DOM2
    // nodeIterator API would be a better technique but not supported by all
    // browsers).
    var iterate = function (el) {
      for (var i = el.firstChild; i != null; i = i.nextSibling) {
        if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
          var mo = re.exec(i.tagName);
          if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
            result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
          }
          iterate(i);
        }
      }
    }
    iterate(el);
    return result;
  }

  var toc = document.getElementById("toc");
  if (!toc) {
    return;
  }

  // Delete existing TOC entries in case we're reloading the TOC.
  var tocEntriesToRemove = [];
  var i;
  for (i = 0; i < toc.childNodes.length; i++) {
    var entry = toc.childNodes[i];
    if (entry.nodeName.toLowerCase() == 'div'
     && entry.getAttribute("class")
     && entry.getAttribute("class").match(/^toclevel/))
      tocEntriesToRemove.push(entry);
  }
  for (i = 0; i < tocEntriesToRemove.length; i++) {
    toc.removeChild(tocEntriesToRemove[i]);
  }

  // Rebuild TOC entries.
  var entries = tocEntries(document.getElementById("content"), toclevels);
  for (var i = 0; i < entries.length; ++i) {
    var entry = entries[i];
    if (entry.element.id == "")
      entry.element.id = "_toc_" + i;
    var a = document.createElement("a");
    a.href = "#" + entry.element.id;
    a.appendChild(document.createTextNode(entry.text));
    var div = document.createElement("div");
    div.appendChild(a);
    div.className = "toclevel" + entry.toclevel;
    toc.appendChild(div);
  }
  if (entries.length == 0)
    toc.parentNode.removeChild(toc);
},


/////////////////////////////////////////////////////////////////////
// Footnotes generator
/////////////////////////////////////////////////////////////////////

/* Based on footnote generation code from:
 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
 */

footnotes: function () {
  // Delete existing footnote entries in case we're reloading the footnodes.
  var i;
  var noteholder = document.getElementById("footnotes");
  if (!noteholder) {
    return;
  }
  var entriesToRemove = [];
  for (i = 0; i < noteholder.childNodes.length; i++) {
    var entry = noteholder.childNodes[i];
    if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
      entriesToRemove.push(entry);
  }
  for (i = 0; i < entriesToRemove.length; i++) {
    noteholder.removeChild(entriesToRemove[i]);
  }

  // Rebuild footnote entries.
  var cont = document.getElementById("content");
  var spans = cont.getElementsByTagName("span");
  var refs = {};
  var n = 0;
  for (i=0; i<spans.length; i++) {
    if (spans[i].className == "footnote") {
      n++;
      var note = spans[i].getAttribute("data-note");
      if (!note) {
        // Use [\s\S] in place of . so multi-line matches work.
        // Because JavaScript has no s (dotall) regex flag.
        note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
        spans[i].innerHTML =
          "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
          "' title='View footnote' class='footnote'>" + n + "</a>]";
        spans[i].setAttribute("data-note", note);
      }
      noteholder.innerHTML +=
        "<div class='footnote' id='_footnote_" + n + "'>" +
        "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
        n + "</a>. " + note + "</div>";
      var id =spans[i].getAttribute("id");
      if (id != null) refs["#"+id] = n;
    }
  }
  if (n == 0)
    noteholder.parentNode.removeChild(noteholder);
  else {
    // Process footnoterefs.
    for (i=0; i<spans.length; i++) {
      if (spans[i].className == "footnoteref") {
        var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
        href = href.match(/#.*/)[0];  // Because IE return full URL.
        n = refs[href];
        spans[i].innerHTML =
          "[<a href='#_footnote_" + n +
          "' title='View footnote' class='footnote'>" + n + "</a>]";
      }
    }
  }
},

install: function(toclevels) {
  var timerId;

  function reinstall() {
    asciidoc.footnotes();
    if (toclevels) {
      asciidoc.toc(toclevels);
    }
  }

  function reinstallAndRemoveTimer() {
    clearInterval(timerId);
    reinstall();
  }

  timerId = setInterval(reinstall, 500);
  if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
  else
    window.onload = reinstallAndRemoveTimer;
}

}
asciidoc.install(2);
/*]]>*/
</script>
</head>
<body class="article">
<div id="header">
<h1>IPC interface (interprocess communication)</h1>
<span id="author">Michael Stapelberg</span><br />
<span id="email"><code>&lt;<a href="mailto:michael@i3wm.org">michael@i3wm.org</a>&gt;</code></span><br />
<span id="revdate">June 2020</span>
<div id="toc">
  <div id="toctitle">Table of Contents</div>
  <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>This document describes how to interface with i3 from a separate process. This
is useful for example to remote-control i3 (to write test cases for example) or
to get various information like the current workspaces to implement an external
workspace bar.</p></div>
<div class="paragraph"><p>The method of choice for IPC in our case is a unix socket because it has very
little overhead on both sides and is usually available without headaches in
most languages.
By default i3 will set the path of the IPC socket based on:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
The <code>ipc-socket</code> configuration directive if it is used
</p>
</li>
<li>
<p>
The <code>I3SOCK</code> environmental variable if it is set
</p>
</li>
<li>
<p>
<code>$XDG_RUNTIME_DIR/i3/ipc-socket.%p</code> if the directory is available where <code>%p</code>
   is the PID of i3 and XXXXXX is a string of random characters
</p>
</li>
<li>
<p>
<code>/tmp/i3-%u.XXXXXX/ipc-socket.%p</code> where <code>%u</code> is your UNIX username
</p>
</li>
</ol></div>
<div class="paragraph"><p>You can get the socketpath from i3 by executing <code>i3 --get-socketpath</code>, which
will print the path to the standard output (plus a newline) or by reading the
<code>I3SOCK</code> environmental variable.</p></div>
<div class="paragraph"><p>All i3 utilities, like <code>i3-msg</code> and <code>i3-input</code> will determine the path of the
IPC socket from the <code>I3SOCK</code> environmental variable if it is set or the
<code>I3_SOCKET_PATH</code> X11 property, stored on the X11 root window.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Warning</div>
</td>
<td class="content">
<div class="title">Use an existing library!</div>There are existing libraries for many languages. You can have a look at
<a href="#libraries">[libraries]</a> or search the web if your language of choice is not mentioned.
Usually, it is not necessary to implement low-level communication with i3
directly.</td>
</tr></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_establishing_a_connection">1. Establishing a connection</h2>
<div class="sectionbody">
<div class="paragraph"><p>To establish a connection, simply open the IPC socket. The following code
snippet illustrates this in Perl:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>use IO::Socket::UNIX;
chomp(my $path = qx(i3 --get-socketpath));
my $sock = IO::Socket::UNIX-&gt;new(Peer =&gt; $path);</code></pre>
</div></div>
</div>
</div>
<div class="sect1">
<h2 id="_sending_messages_to_i3">2. Sending messages to i3</h2>
<div class="sectionbody">
<div class="paragraph"><p>To send a message to i3, you have to format it in the binary message format
which i3 expects. This format specifies a magic string in the beginning to
ensure the integrity of messages (to prevent follow-up errors). Following the
magic string comes the length of the payload of the message as a 32-bit
integer, and the type of the message as a 32-bit integer (the integers are not
converted, so they are in native byte order).</p></div>
<div class="paragraph"><p>The magic string currently is "i3-ipc" and will only be changed when a change
in the IPC API is done which breaks compatibility (we hope that we don’t need
to do that).</p></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<caption class="title">Table 1. Currently implemented message types</caption>
<col width="10%" />
<col width="20%" />
<col width="20%" />
<col width="50%" />
<thead>
<tr>
<th align="center" valign="top"> Type (numeric) </th>
<th align="center" valign="top"> Type (name) </th>
<th align="center" valign="top"> Reply type </th>
<th align="center" valign="top"> Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center" valign="top"><p class="table">0</p></td>
<td align="center" valign="top"><p class="table"><code>RUN_COMMAND</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_command_reply">COMMAND</a></p></td>
<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>
</tr>
<tr>
<td align="center" valign="top"><p class="table">1</p></td>
<td align="center" valign="top"><p class="table"><code>GET_WORKSPACES</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_workspaces_reply">WORKSPACES</a></p></td>
<td align="center" valign="top"><p class="table">Get the list of current workspaces.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">2</p></td>
<td align="center" valign="top"><p class="table"><code>SUBSCRIBE</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_subscribe_reply">SUBSCRIBE</a></p></td>
<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>
</tr>
<tr>
<td align="center" valign="top"><p class="table">3</p></td>
<td align="center" valign="top"><p class="table"><code>GET_OUTPUTS</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_outputs_reply">OUTPUTS</a></p></td>
<td align="center" valign="top"><p class="table">Get the list of current outputs.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">4</p></td>
<td align="center" valign="top"><p class="table"><code>GET_TREE</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_tree_reply">TREE</a></p></td>
<td align="center" valign="top"><p class="table">Get the i3 layout tree.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">5</p></td>
<td align="center" valign="top"><p class="table"><code>GET_MARKS</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_marks_reply">MARKS</a></p></td>
<td align="center" valign="top"><p class="table">Gets the names of all currently set marks.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">6</p></td>
<td align="center" valign="top"><p class="table"><code>GET_BAR_CONFIG</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_bar_config_reply">BAR_CONFIG</a></p></td>
<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>
</tr>
<tr>
<td align="center" valign="top"><p class="table">7</p></td>
<td align="center" valign="top"><p class="table"><code>GET_VERSION</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_version_reply">VERSION</a></p></td>
<td align="center" valign="top"><p class="table">Gets the i3 version.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">8</p></td>
<td align="center" valign="top"><p class="table"><code>GET_BINDING_MODES</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_binding_modes_reply">BINDING_MODES</a></p></td>
<td align="center" valign="top"><p class="table">Gets the names of all currently configured binding modes.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">9</p></td>
<td align="center" valign="top"><p class="table"><code>GET_CONFIG</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_config_reply">CONFIG</a></p></td>
<td align="center" valign="top"><p class="table">Returns the last loaded i3 config.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">10</p></td>
<td align="center" valign="top"><p class="table"><code>SEND_TICK</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_tick_reply">TICK</a></p></td>
<td align="center" valign="top"><p class="table">Sends a tick event with the specified payload.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">11</p></td>
<td align="center" valign="top"><p class="table"><code>SYNC</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_sync_reply">SYNC</a></p></td>
<td align="center" valign="top"><p class="table">Sends an i3 sync event with the specified random value to the specified window.</p></td>
</tr>
<tr>
<td align="center" valign="top"><p class="table">12</p></td>
<td align="center" valign="top"><p class="table"><code>GET_BINDING_STATE</code></p></td>
<td align="center" valign="top"><p class="table"><a href="#_binding_state_reply">BINDING_STATE</a></p></td>
<td align="center" valign="top"><p class="table">Request the current binding state, i.e. the currently active binding mode name.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="paragraph"><p>So, a typical message could look like this:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>"i3-ipc" &lt;message length&gt; &lt;message type&gt; &lt;payload&gt;</code></pre>
</div></div>
<div class="paragraph"><p>Or, as a hexdump:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>00000000  69 33 2d 69 70 63 04 00  00 00 00 00 00 00 65 78  |i3-ipc........ex|
00000010  69 74                                             |it|</code></pre>
</div></div>
<div class="paragraph"><p>To generate and send such a message, you could use the following code in Perl:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>sub format_ipc_command {
    my ($msg) = @_;
    my $len;
    # Get the real byte count (vs. amount of characters)
    { use bytes; $len = length($msg); }
    return "i3-ipc" . pack("LL", $len, 0) . $msg;
}

$sock-&gt;write(format_ipc_command("exit"));</code></pre>
</div></div>
</div>
</div>
<div class="sect1">
<h2 id="_receiving_replies_from_i3">3. Receiving replies from i3</h2>
<div class="sectionbody">
<div class="paragraph"><p>Each message sent to i3 will cause exactly one reply to be sent in return. The
order of the sent replies will always correspond to the order of the sent
requests. The only exception to this is <a href="#events">[events]</a>, which (once subscribed to)
may be sent at any time (though never in the middle of another event or reply).</p></div>
<div class="paragraph"><p>It is generally safe to send several messages to i3 without first waiting for a
reply for each one (pipelining)&#8201;&#8212;&#8201;though, note that depending on the language /
network library you use, writing to the socket without also reading from it may
cause a deadlock due to the socket buffers getting full.</p></div>
<div class="paragraph"><p>The reply format is identical to the normal message format. There also is
the magic string, then the message length, then the message type and the
payload.</p></div>
<div class="paragraph"><p>The payload of replies from i3 usually consists of a simple string (the length
of the string is the message_length, so you can consider them length-prefixed),
which in turn contain the JSON serialization of a data structure. For example,
the GET_WORKSPACES message returns an array of workspaces (each workspace is a
map with certain attributes).</p></div>
<div class="paragraph"><p>Replies currently have a 1:1 correspondence to messages, with the message type
of the reply corresponding to the message type of the message which caused the
reply to be sent.</p></div>
<div class="paragraph"><p>The following reply types are implemented:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
COMMAND (0)
</dt>
<dd>
<p>
        Confirmation/Error code for the RUN_COMMAND message.
</p>
</dd>
<dt class="hdlist1">
WORKSPACES (1)
</dt>
<dd>
<p>
        Reply to the GET_WORKSPACES message.
</p>
</dd>
<dt class="hdlist1">
SUBSCRIBE (2)
</dt>
<dd>
<p>
        Confirmation/Error code for the SUBSCRIBE message.
</p>
</dd>
<dt class="hdlist1">
OUTPUTS (3)
</dt>
<dd>
<p>
        Reply to the GET_OUTPUTS message.
</p>
</dd>
<dt class="hdlist1">
TREE (4)
</dt>
<dd>
<p>
        Reply to the GET_TREE message.
</p>
</dd>
<dt class="hdlist1">
MARKS (5)
</dt>
<dd>
<p>
        Reply to the GET_MARKS message.
</p>
</dd>
<dt class="hdlist1">
BAR_CONFIG (6)
</dt>
<dd>
<p>
        Reply to the GET_BAR_CONFIG message.
</p>
</dd>
<dt class="hdlist1">
VERSION (7)
</dt>
<dd>
<p>
        Reply to the GET_VERSION message.
</p>
</dd>
<dt class="hdlist1">
BINDING_MODES (8)
</dt>
<dd>
<p>
        Reply to the GET_BINDING_MODES message.
</p>
</dd>
<dt class="hdlist1">
GET_CONFIG (9)
</dt>
<dd>
<p>
        Reply to the GET_CONFIG message.
</p>
</dd>
<dt class="hdlist1">
TICK (10)
</dt>
<dd>
<p>
        Reply to the SEND_TICK message.
</p>
</dd>
<dt class="hdlist1">
SYNC (11)
</dt>
<dd>
<p>
        Reply to the SYNC message.
</p>
</dd>
<dt class="hdlist1">
GET_BINDING_STATE (12)
</dt>
<dd>
<p>
        Reply to the GET_BINDING_STATE message.
</p>
</dd>
</dl></div>
</div>
</div>
<div class="sect1">
<h2 id="_messages_and_replies">4. Messages and replies</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_command_reply">4.1. RUN_COMMAND / COMMAND</h3>
<div class="paragraph"><p>Run the payload as an <a href="https://i3wm.org/docs/userguide.html#list_of_commands">i3
command</a> (like the commands you can bind to keys).</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>The message payload is the string containing the command to execute. There is
no JSON encoding or trailing newline.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a list of serialized maps for each command that was
parsed. Each has the property <code>success (bool)</code> and may also include a
human-readable error message in the property <code>error (string)</code>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">When sending the <code>restart</code> command, you will get a singular reply once the
restart completed. All IPC connection states (e.g. subscriptions) will reset and
all but one socket will be closed. Libraries must be able to cope with this by
aligning their internal states. It is also recommended that libraries close
the last remaining socket(one which replied to <code>restart</code> command) to achieve
the full reset.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">It is easiest to always send the <code>restart</code> command alone: due to i3’s
state reset, the reply messages of preceding commands are lost, and following
commands will not be executed.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">When processing the <code>exit</code> command, i3 will immediately exit without
sending a reply. Expect the socket to be shut down.</td>
</tr></table>
</div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>[{ "success": true }]</code></pre>
</div></div>
<div class="paragraph"><p>When the specified command cannot be parsed, <code>success</code> will be false and
<code>parse_error</code> will be true:</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>[{ "success": false, "parse_error": true }]</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_workspaces_reply">4.2. GET_WORKSPACES / WORKSPACES</h3>
<div class="paragraph"><p>Get the list of current workspaces.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a serialized list of workspaces. Each workspace has the
following properties:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
id (integer)
</dt>
<dd>
<p>
        The internal ID (actually a C pointer value) of this container. Do not
        make any assumptions about it. You can use it to (re-)identify and
        address containers when talking to i3.
</p>
</dd>
<dt class="hdlist1">
num (integer)
</dt>
<dd>
<p>
        The logical number of the workspace. Corresponds to the command
        to switch to this workspace. For named workspaces, this will be -1.
</p>
</dd>
<dt class="hdlist1">
name (string)
</dt>
<dd>
<p>
        The name of this workspace if changed by the user, otherwise defaults
        to the string representation of the <code>num</code> field). Encoded in UTF-8.
</p>
</dd>
<dt class="hdlist1">
visible (boolean)
</dt>
<dd>
<p>
        Whether this workspace is currently visible on an output (multiple
        workspaces can be visible at the same time).
</p>
</dd>
<dt class="hdlist1">
focused (boolean)
</dt>
<dd>
<p>
        Whether this workspace currently has the focus (only one workspace
        can have the focus at the same time).
</p>
</dd>
<dt class="hdlist1">
urgent (boolean)
</dt>
<dd>
<p>
        Whether a window on this workspace has the "urgent" flag set.
</p>
</dd>
<dt class="hdlist1">
rect (map)
</dt>
<dd>
<p>
        The rectangle of this workspace (equals the rect of the output it
        is on), consists of x, y, width, height.
</p>
</dd>
<dt class="hdlist1">
output (string)
</dt>
<dd>
<p>
        The video output this workspace is on (LVDS1, VGA1, …).
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>[
 {
  "num": 0,
  "name": "1",
  "visible": true,
  "focused": true,
  "urgent": false,
  "rect": {
   "x": 0,
   "y": 0,
   "width": 1280,
   "height": 800
  },
  "output": "LVDS1"
 },
 {
  "num": 1,
  "name": "2",
  "visible": false,
  "focused": false,
  "urgent": false,
  "rect": {
   "x": 0,
   "y": 0,
   "width": 1280,
   "height": 800
  },
  "output": "LVDS1"
 }
]</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_subscribe_reply">4.3. SUBSCRIBE</h3>
<div class="paragraph"><p>Subscribe this IPC connection to the event types specified in the message
payload. See <a href="#events">[events]</a>.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>A JSON-encoded array of event types to subscribe to.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a single serialized map. The only property is
<code>success (bool)</code>, indicating whether the subscription was successful (the
default) or whether a JSON parse error occurred.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{ "success": true }</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_outputs_reply">4.4. GET_OUTPUTS / OUTPUTS</h3>
<div class="paragraph"><p>Get the list of current outputs.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a serialized list of outputs. Each output has the
following properties:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
name (string)
</dt>
<dd>
<p>
        The name of this output (as seen in <code>xrandr(1)</code>). Encoded in UTF-8.
</p>
</dd>
<dt class="hdlist1">
active (boolean)
</dt>
<dd>
<p>
        Whether this output is currently active (has a valid mode).
</p>
</dd>
<dt class="hdlist1">
primary (boolean)
</dt>
<dd>
<p>
        Whether this output is currently the primary output.
</p>
</dd>
<dt class="hdlist1">
current_workspace (string or null)
</dt>
<dd>
<p>
        The name of the current workspace that is visible on this output. <code>null</code> if
        the output is not active.
</p>
</dd>
<dt class="hdlist1">
rect (map)
</dt>
<dd>
<p>
        The rectangle of this output (equals the rect of the output it
        is on), consists of x, y, width, height.
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>[
 {
  "name": "LVDS1",
  "active": true,
  "current_workspace": "4",
  "rect": {
   "x": 0,
   "y": 0,
   "width": 1280,
   "height": 800
  }
 },
 {
  "name": "VGA1",
  "active": true,
  "current_workspace": "1",
  "rect": {
   "x": 1280,
   "y": 0,
   "width": 1280,
   "height": 1024
  }
 }
]</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_tree_reply">4.5. GET_TREE / TREE</h3>
<div class="paragraph"><p>Get the i3 layout tree.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a serialized tree. Each node in the tree (representing
one container) has at least the properties listed below. While the nodes might
have more properties, please do not use any properties which are not documented
here. They are not yet finalized and will probably change!</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
id (integer)
</dt>
<dd>
<p>
        The internal ID (actually a C pointer value) of this container. Do not
        make any assumptions about it. You can use it to (re-)identify and
        address containers when talking to i3.
</p>
</dd>
<dt class="hdlist1">
name (string)
</dt>
<dd>
<p>
        The internal name of this container. For all containers which are part
        of the tree structure down to the workspace contents, this is set to a
        nice human-readable name of the container.
        For containers that have an X11 window, the content is the title
        (_NET_WM_NAME property) of that window.
        For all other containers, the content is not defined (yet).
</p>
</dd>
<dt class="hdlist1">
type (string)
</dt>
<dd>
<p>
        Type of this container. Can be one of "root", "output", "con",
        "floating_con", "workspace" or "dockarea".
</p>
</dd>
<dt class="hdlist1">
border (string)
</dt>
<dd>
<p>
        Can be either "normal", "none" or "pixel", depending on the
        container’s border style.
</p>
</dd>
<dt class="hdlist1">
current_border_width (integer)
</dt>
<dd>
<p>
        Number of pixels of the border width.
</p>
</dd>
<dt class="hdlist1">
layout (string)
</dt>
<dd>
<p>
        Can be either "splith", "splitv", "stacked", "tabbed", "dockarea" or
        "output".
        Other values might be possible in the future, should we add new
        layouts.
</p>
</dd>
<dt class="hdlist1">
orientation (string)
</dt>
<dd>
<p>
        Can be either "none" (for non-split containers), "horizontal" or
        "vertical".
        THIS FIELD IS OBSOLETE. It is still present, but your code should not
        use it. Instead, rely on the layout field.
</p>
</dd>
<dt class="hdlist1">
percent (float or null)
</dt>
<dd>
<p>
        The percentage which this container takes in its parent. A value of
        <code>null</code> means that the percent property does not make sense for this
        container, for example for the root container.
</p>
</dd>
<dt class="hdlist1">
rect (map)
</dt>
<dd>
<p>
        The absolute display coordinates for this container. Display
        coordinates means that when you have two 1600x1200 monitors on a single
        X11 Display (the standard way), the coordinates of the first window on
        the second monitor are <code>{ "x": 1600, "y": 0, "width": 1600, "height":
        1200 }</code>.
</p>
</dd>
<dt class="hdlist1">
window_rect (map)
</dt>
<dd>
<p>
        The coordinates of the <strong>actual client window</strong> inside its container.
        These coordinates are relative to the container and do not include the
        window decoration (which is actually rendered on the parent container).
        So, when using the <code>default</code> layout, you will have a 2 pixel border on
        each side, making the window_rect <code>{ "x": 2, "y": 0, "width": 632,
        "height": 366 }</code> (for example).
</p>
</dd>
<dt class="hdlist1">
deco_rect (map)
</dt>
<dd>
<p>
        The coordinates of the <strong>window decoration</strong> inside its container. These
        coordinates are relative to the container and do not include the actual
        client window.
</p>
</dd>
<dt class="hdlist1">
actual_deco_rect (map)
</dt>
<dd>
<p>
        See <code>deco_rect</code>. i3 v4.22 changed the way title bars are rendered. Before
        i3 v4.22, the deco_rect was always relative to the parent coordinates.
        Starting with i3 v4.22, this remains true for tabbed/stacked containers
        (actual_deco_rect is identical to deco_rect), but for normal-border leaf
        containers within vertical/horizontal split containers, actual_deco_rect
        is relative to the container itself. For more background, see
        <a href="https://github.com/i3/i3/issues/1966">https://github.com/i3/i3/issues/1966</a>
</p>
</dd>
<dt class="hdlist1">
geometry (map)
</dt>
<dd>
<p>
        The original geometry the window specified when i3 mapped it. Used when
        switching a window to floating mode, for example.
</p>
</dd>
<dt class="hdlist1">
window (integer or null)
</dt>
<dd>
<p>
        The X11 window ID of the <strong>actual client window</strong> inside this container.
        This field is set to <code>null</code> for split containers or otherwise empty
        containers. This ID corresponds to what xwininfo(1) and other
        X11-related tools display (usually in hex).
</p>
</dd>
<dt class="hdlist1">
window_properties (map)
</dt>
<dd>
<p>
        This optional field contains all available X11 window properties from the
        following list: <strong>title</strong>, <strong>instance</strong>, <strong>class</strong>, <strong>window_role</strong>, <strong>machine</strong>
        and <strong>transient_for</strong>.
</p>
</dd>
<dt class="hdlist1">
window_type (string)
</dt>
<dd>
<p>
        The window type (_NET_WM_WINDOW_TYPE). Possible values are <code>undefined</code>,
        unknown, normal, dialog, utility, toolbar, splash, menu, dropdown_menu,
        popup_menu, tooltip and notification.
</p>
</dd>
<dt class="hdlist1">
urgent (bool)
</dt>
<dd>
<p>
        Whether this container (window, split container, floating container or
        workspace) has the urgency hint set, directly or indirectly. All parent
        containers up until the workspace container will be marked urgent if they
        have at least one urgent child.
</p>
</dd>
<dt class="hdlist1">
marks (array of string)
</dt>
<dd>
<p>
        List of marks assigned to container
</p>
</dd>
<dt class="hdlist1">
focused (bool)
</dt>
<dd>
<p>
        Whether this container is currently focused.
</p>
</dd>
<dt class="hdlist1">
focus (array of integer)
</dt>
<dd>
<p>
        List of child node IDs (see <code>nodes</code>, <code>floating_nodes</code> and <code>id</code>) in focus
        order. Traversing the tree by following the first entry in this array
        will result in eventually reaching the one node with <code>focused</code> set to
        true.
</p>
</dd>
<dt class="hdlist1">
sticky (bool)
</dt>
<dd>
<p>
        Whether this window is "sticky". If it is also floating, this window will
        be present on all workspaces on the same output.
</p>
</dd>
<dt class="hdlist1">
fullscreen_mode (integer)
</dt>
<dd>
<p>
        Whether this container is in fullscreen state or not.
    Possible values are
        <code>0</code> (no fullscreen),
        <code>1</code> (fullscreened on output) or
        <code>2</code> (fullscreened globally).
    Note that all workspaces are considered fullscreened on their respective output.
</p>
</dd>
<dt class="hdlist1">
floating (string)
</dt>
<dd>
<p>
        Floating state of container.
        Can be either "auto_on", "auto_off", "user_on" or "user_off"
</p>
</dd>
<dt class="hdlist1">
nodes (array of node)
</dt>
<dd>
<p>
        The tiling (i.e. non-floating) child containers of this node.
</p>
</dd>
<dt class="hdlist1">
floating_nodes (array of node)
</dt>
<dd>
<p>
        The floating child containers of this node. Only non-empty on nodes with
        type <code>workspace</code>.
</p>
</dd>
<dt class="hdlist1">
scratchpad_state (string)
</dt>
<dd>
<p>
        Whether the window is not in the scratchpad ("none"), freshly moved to
        the scratchpad but not yet resized ("fresh") or moved to the scratchpad
        and resized ("changed").
</p>
</dd>
</dl></div>
<div class="paragraph"><p>Please note that in the following example, I have left out some keys/values
which are not relevant for the type of the node. Otherwise, the example would
be by far too long (it already is quite long, despite showing only 1 window and
one dock window).</p></div>
<div class="paragraph"><p>It is useful to have an overview of the structure before taking a look at the
JSON dump:</p></div>
<div class="ulist"><ul>
<li>
<p>
root
</p>
<div class="ulist"><ul>
<li>
<p>
LVDS1
</p>
<div class="ulist"><ul>
<li>
<p>
topdock
</p>
</li>
<li>
<p>
content
</p>
<div class="ulist"><ul>
<li>
<p>
workspace 1
</p>
<div class="ulist"><ul>
<li>
<p>
window 1
</p>
</li>
</ul></div>
</li>
</ul></div>
</li>
<li>
<p>
bottomdock
</p>
<div class="ulist"><ul>
<li>
<p>
dock window 1
</p>
</li>
</ul></div>
</li>
</ul></div>
</li>
<li>
<p>
VGA1
</p>
</li>
</ul></div>
</li>
</ul></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "id": 6875648,
 "name": "root",
 "rect": {
   "x": 0,
   "y": 0,
   "width": 1280,
   "height": 800
 },
 "nodes": [

   {
    "id": 6878320,
    "name": "LVDS1",
    "layout": "output",
    "rect": {
      "x": 0,
      "y": 0,
      "width": 1280,
      "height": 800
    },
    "nodes": [

      {
       "id": 6878784,
       "name": "topdock",
       "layout": "dockarea",
       "orientation": "vertical",
       "rect": {
         "x": 0,
         "y": 0,
         "width": 1280,
         "height": 0
       }
      },

      {
       "id": 6879344,
       "name": "content",
       "rect": {
         "x": 0,
         "y": 0,
         "width": 1280,
         "height": 782
       },
       "nodes": [

         {
          "id": 6880464,
          "name": "1",
          "orientation": "horizontal",
          "rect": {
            "x": 0,
            "y": 0,
            "width": 1280,
            "height": 782
          },
          "window_properties": {
            "class": "Evince",
            "instance": "evince",
            "title": "Properties",
            "transient_for": 52428808
          },
          "floating_nodes": [],
          "nodes": [

            {
             "id": 6929968,
             "name": "#aa0000",
             "border": "normal",
             "percent": 1,
             "rect": {
               "x": 0,
               "y": 18,
               "width": 1280,
               "height": 782
             }
            }

          ]
         }

       ]
      },

      {
       "id": 6880208,
       "name": "bottomdock",
       "layout": "dockarea",
       "orientation": "vertical",
       "rect": {
         "x": 0,
         "y": 782,
         "width": 1280,
         "height": 18
       },
       "nodes": [

         {
          "id": 6931312,
          "name": "#00aa00",
          "percent": 1,
          "rect": {
            "x": 0,
            "y": 782,
            "width": 1280,
            "height": 18
          }
         }

       ]
      }
    ]
   }
 ]
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_marks_reply">4.6. GET_MARKS / MARKS</h3>
<div class="paragraph"><p>Gets the names of all currently set marks.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a single array of strings for each container that has a
mark. A mark can only be set on one container, so the array is unique.
The order of that array is undefined.</p></div>
<div class="paragraph"><p>If no window has a mark the response will be the empty array [].</p></div>
</div>
<div class="sect2">
<h3 id="_bar_config_reply">4.7. GET_BAR_CONFIG / BAR_CONFIG</h3>
<div class="paragraph"><p>Gets the specified bar configuration or the names of all bar configurations if payload is empty.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload, or the ID of the bar whose configuration to retrieve.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>This can be used by third-party workspace bars (especially i3bar, but others
are free to implement compatible alternatives) to get the <code>bar</code> block
configuration from i3.</p></div>
<div class="paragraph"><p>Depending on the input, the reply is either:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
empty input
</dt>
<dd>
<p>
        An array of configured bar IDs
</p>
</dd>
<dt class="hdlist1">
Bar ID
</dt>
<dd>
<p>
        A JSON map containing the configuration for the specified bar.
</p>
</dd>
</dl></div>
<div class="paragraph"><p>Each bar configuration has the following properties:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
id (string)
</dt>
<dd>
<p>
        The ID for this bar. Included in case you request multiple
        configurations and want to differentiate the different replies.
</p>
</dd>
<dt class="hdlist1">
mode (string)
</dt>
<dd>
<p>
        Either <code>dock</code> (the bar sets the dock window type) or <code>hide</code> (the bar
        does not show unless a specific key is pressed).
</p>
</dd>
<dt class="hdlist1">
position (string)
</dt>
<dd>
<p>
        Either <code>bottom</code> or <code>top</code> at the moment.
</p>
</dd>
<dt class="hdlist1">
status_command (string)
</dt>
<dd>
<p>
        Command which will be run to generate a statusline. Each line on stdout
        of this command will be displayed in the bar. At the moment, no
        formatting is supported.
</p>
</dd>
<dt class="hdlist1">
font (string)
</dt>
<dd>
<p>
        The font to use for text on the bar.
</p>
</dd>
<dt class="hdlist1">
workspace_buttons (boolean)
</dt>
<dd>
<p>
        Display workspace buttons or not? Defaults to true.
</p>
</dd>
<dt class="hdlist1">
binding_mode_indicator (boolean)
</dt>
<dd>
<p>
        Display the mode indicator or not? Defaults to true.
</p>
</dd>
<dt class="hdlist1">
verbose (boolean)
</dt>
<dd>
<p>
        Should the bar enable verbose output for debugging? Defaults to false.
</p>
</dd>
<dt class="hdlist1">
colors (map)
</dt>
<dd>
<p>
        Contains key/value pairs of colors. Each value is a color code in hex,
        formatted #rrggbb (like in HTML).
</p>
</dd>
</dl></div>
<div class="paragraph"><p>The following colors can be configured at the moment:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
background
</dt>
<dd>
<p>
        Background color of the bar.
</p>
</dd>
<dt class="hdlist1">
statusline
</dt>
<dd>
<p>
        Text color to be used for the statusline.
</p>
</dd>
<dt class="hdlist1">
separator
</dt>
<dd>
<p>
        Text color to be used for the separator.
</p>
</dd>
<dt class="hdlist1">
focused_background
</dt>
<dd>
<p>
        Background color of the bar on the currently focused monitor output.
</p>
</dd>
<dt class="hdlist1">
focused_statusline
</dt>
<dd>
<p>
        Text color to be used for the statusline on the currently focused
        monitor output.
</p>
</dd>
<dt class="hdlist1">
focused_separator
</dt>
<dd>
<p>
        Text color to be used for the separator on the currently focused
        monitor output.
</p>
</dd>
<dt class="hdlist1">
focused_workspace_text/focused_workspace_bg/focused_workspace_border
</dt>
<dd>
<p>
        Text/background/border color for a workspace button when the workspace
        has focus.
</p>
</dd>
<dt class="hdlist1">
active_workspace_text/active_workspace_bg/active_workspace_border
</dt>
<dd>
<p>
        Text/background/border color for a workspace button when the workspace
        is active (visible) on some output, but the focus is on another one.
        You can only tell this apart from the focused workspace when you are
        using multiple monitors.
</p>
</dd>
<dt class="hdlist1">
inactive_workspace_text/inactive_workspace_bg/inactive_workspace_border
</dt>
<dd>
<p>
        Text/background/border color for a workspace button when the workspace
        does not have focus and is not active (visible) on any output. This
        will be the case for most workspaces.
</p>
</dd>
<dt class="hdlist1">
urgent_workspace_text/urgent_workspace_bg/urgent_workspace_border
</dt>
<dd>
<p>
        Text/background/border color for workspaces which contain at least one
        window with the urgency hint set.
</p>
</dd>
<dt class="hdlist1">
binding_mode_text/binding_mode_bg/binding_mode_border
</dt>
<dd>
<p>
        Text/background/border color for the binding mode indicator.
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example of configured bars:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>["bar-bxuqzf"]</code></pre>
</div></div>
<div class="paragraph"><p><strong>Example of bar configuration:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "id": "bar-bxuqzf",
 "mode": "dock",
 "position": "bottom",
 "status_command": "i3status",
 "font": "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1",
 "workspace_buttons": true,
 "binding_mode_indicator": true,
 "verbose": false,
 "colors": {
   "background": "#c0c0c0",
   "statusline": "#00ff00",
   "focused_workspace_text": "#ffffff",
   "focused_workspace_bg": "#000000"
 }
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_version_reply">4.8. GET_VERSION / VERSION</h3>
<div class="paragraph"><p>Gets the i3 version.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of a single JSON dictionary with the following keys:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
major (integer)
</dt>
<dd>
<p>
        The major version of i3, such as <code>4</code>.
</p>
</dd>
<dt class="hdlist1">
minor (integer)
</dt>
<dd>
<p>
        The minor version of i3, such as <code>2</code>. Changes in the IPC interface (new
        features) will only occur with new minor (or major) releases. However,
        bugfixes might be introduced in patch releases, too.
</p>
</dd>
<dt class="hdlist1">
patch (integer)
</dt>
<dd>
<p>
        The patch version of i3, such as <code>1</code> (when the complete version is
        <code>4.2.1</code>). For versions such as <code>4.2</code>, patch will be set to <code>0</code>.
</p>
</dd>
<dt class="hdlist1">
human_readable (string)
</dt>
<dd>
<p>
        A human-readable version of i3 containing the precise git version,
        build date and branch name. When you need to display the i3 version to
        your users, use the human-readable version whenever possible (since
        this is what <code>i3 --version</code> displays, too).
</p>
</dd>
<dt class="hdlist1">
loaded_config_file_name (string)
</dt>
<dd>
<p>
        The current config path.
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
   "human_readable" : "4.2-169-gf80b877 (2012-08-05, branch \"next\")",
   "loaded_config_file_name" : "/home/hwangcc23/.i3/config",
   "minor" : 2,
   "patch" : 0,
   "major" : 4
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_binding_modes_reply">4.9. GET_BINDING_MODES / BINDING_MODES</h3>
<div class="paragraph"><p>Gets the names of all currently configured binding modes.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply consists of an array of all currently configured binding modes.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>["default", "resize"]</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_config_reply">4.10. GET_CONFIG / CONFIG</h3>
<div class="paragraph"><p>Returns the last loaded i3 config.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The config reply is a map which contains the following fields:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
config (string)
</dt>
<dd>
<p>
        The top-level config file contents that i3 has loaded most recently.
        This field is kept for backwards compatibility. See <code>included_configs</code>
        instead.
</p>
</dd>
<dt class="hdlist1">
included_configs (array of maps)
</dt>
<dd>
<p>
        i3 adds one entry to this array for each config file it loads, in
        order. The first entry’s <code>raw_contents</code> are identical to the <code>config</code>
        field.
</p>
</dd>
</dl></div>
<div class="paragraph"><p>Each <code>included_configs</code> entry contains the following fields</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
path (string)
</dt>
<dd>
<p>
        Absolute path name to the config file that i3 loaded.
</p>
</dd>
<dt class="hdlist1">
raw_contents (string)
</dt>
<dd>
<p>
        The raw contents of the file as i3 read them.
</p>
</dd>
<dt class="hdlist1">
variable_replaced_contents (string)
</dt>
<dd>
<p>
        The contents of the file after i3 replaced all variables. This is useful
        for debugging variable replacement.
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
  "config": "include font.cfg\n",
  "included_configs": [
    {
      "path": "/home/michael/configfiles/i3/config",
      "raw_contents": "include font.cfg\n",
      "variable_replaced_contents": "include font.cfg\n"
    },
    {
      "path": "/home/michael/configfiles/i3/font.cfg",
      "raw_contents": "set $font pango:monospace 8\nfont $font",
      "variable_replaced_contents": "set pango:monospace 8 pango:monospace 8\nfont pango:monospace 8\n"
    }
  ],
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_tick_reply">4.11. SEND_TICK / TICK</h3>
<div class="paragraph"><p>Sends a tick event with the specified payload.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>The payload of the tick event to send to IPC event listeners.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply is a map containing the "success" member. After the reply was
received, the tick event has been written to all IPC connections which subscribe
to tick events. UNIX sockets are usually buffered, but you can be certain that
once you receive the tick event you just triggered, you must have received all
events generated prior to the <code>SEND_TICK</code> message (happened-before relation).</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{ "success": true }</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_sync_reply">4.12. SYNC</h3>
<div class="paragraph"><p>Sends an i3 sync event with the specified random value to the specified window.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>A JSON-encoded map with the properties "rnd" and "window" (both integer).</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The reply is a map containing the "success" member. After the reply was
received, the <a href="https://i3wm.org/docs/testsuite.html#i3_sync">i3 sync message</a> was
responded to.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{ "success": true }</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_binding_state_reply">4.13. GET_BINDING_STATE</h3>
<div class="paragraph"><p>Request the current binding state, i.e. the currently active binding mode name.</p></div>
<div class="paragraph"><p><strong>Message:</strong></p></div>
<div class="paragraph"><p>No payload.</p></div>
<div class="paragraph"><p><strong>Reply:</strong></p></div>
<div class="paragraph"><p>The binding_state reply is a map which currently only contains the "name"
member, which is the name of the currently active binding mode as a string.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{ "name": "default" }</code></pre>
</div></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_events">5. Events</h2>
<div class="sectionbody">
<div class="paragraph" id="events"><p>To get informed when certain things happen in i3, clients can subscribe to
events. Events consist of a name (like "workspace") and an event reply type
(like I3_IPC_EVENT_WORKSPACE). Events sent by i3 follow a format similar to
replies but with the highest bit of the message type set to 1 to indicate an
event reply instead of a normal reply. Note that event types and reply types
do not follow the same enumeration scheme (e.g. event type 0 corresponds to the
workspace event however reply type 0 corresponds to the COMMAND reply).</p></div>
<div class="paragraph"><p>Caveat: As soon as you subscribe to an event, it is not guaranteed any longer
that the requests to i3 are processed in order. This means, the following
situation can happen: You send a GET_WORKSPACES request but you receive a
"workspace" event before receiving the reply to GET_WORKSPACES. If your
program does not want to cope which such kinds of race conditions (an
event based library may not have a problem here), I suggest you create a
separate connection to receive events.</p></div>
<div class="paragraph"><p>If an event message needs to be sent and the socket is not writeable (write
returns EAGAIN, happens when the socket doesn&#8217;t have enough buffer space for
writing new data) then i3 uses a queue system to store outgoing messages for
each client. This is combined with a timer: if the message queue for a client is
not empty and no data where successfully written in the past 10 seconds, the
connection is killed. Practically, this means that your client should try to
always read events from the socket to avoid having its connection closed.</p></div>
<div class="sect2">
<h3 id="_subscribing_to_events">5.1. Subscribing to events</h3>
<div class="paragraph"><p>By sending a message of type SUBSCRIBE with a JSON-encoded array as payload
you can register to an event.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>type: SUBSCRIBE
payload: [ "workspace", "output" ]</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_available_events">5.2. Available events</h3>
<div class="paragraph"><p>The numbers in parenthesis is the event type (keep in mind that you need to
strip the highest bit first).</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
workspace (0)
</dt>
<dd>
<p>
        Sent when the user switches to a different workspace, when a new
        workspace is initialized or when a workspace is removed (because the
        last client vanished).
</p>
</dd>
<dt class="hdlist1">
output (1)
</dt>
<dd>
<p>
        Sent when RandR issues a change notification (of either screens,
        outputs, CRTCs or output properties).
</p>
</dd>
<dt class="hdlist1">
mode (2)
</dt>
<dd>
<p>
        Sent whenever i3 changes its binding mode.
</p>
</dd>
<dt class="hdlist1">
window (3)
</dt>
<dd>
<p>
        Sent when a client&#8217;s window is successfully reparented (that is when i3
        has finished fitting it into a container), when a window received input
        focus or when certain properties of the window have changed.
</p>
</dd>
<dt class="hdlist1">
barconfig_update (4)
</dt>
<dd>
<p>
    Sent when the hidden_state or mode field in the barconfig of any bar
    instance was updated and when the config is reloaded.
</p>
</dd>
<dt class="hdlist1">
binding (5)
</dt>
<dd>
<p>
        Sent when a configured command binding is triggered with the keyboard or
        mouse
</p>
</dd>
<dt class="hdlist1">
shutdown (6)
</dt>
<dd>
<p>
        Sent when the ipc shuts down because of a restart or exit by user command
</p>
</dd>
<dt class="hdlist1">
tick (7)
</dt>
<dd>
<p>
        Sent when the ipc client subscribes to the tick event (with <code>"first":
        true</code>) or when any ipc client sends a SEND_TICK message (with <code>"first":
        false</code>).
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code># the appropriate 4 bytes read from the socket are stored in $input

# unpack a 32-bit unsigned integer
my $message_type = unpack("L", $input);

# check if the highest bit is 1
my $is_event = (($message_type &gt;&gt; 31) == 1);

# use the other bits
my $event_type = ($message_type &amp; 0x7F);

if ($is_event) {
  say "Received event of type $event_type";
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_workspace_event">5.3. workspace event</h3>
<div class="paragraph"><p>This event consists of a single serialized map containing a property
<code>change (string)</code> which indicates the type of the change.</p></div>
<div class="ulist"><ul>
<li>
<p>
<code>empty</code> – the workspace has become empty
</p>
</li>
<li>
<p>
<code>focus</code> – the workspace has received input focus
</p>
</li>
<li>
<p>
<code>init</code> – the workspace has been created
</p>
</li>
<li>
<p>
<code>move</code> – the workspace has been moved to a different output
</p>
</li>
<li>
<p>
<code>reload</code> – i3 config has been reloaded
</p>
</li>
<li>
<p>
<code>rename</code> – the workspace&#8217;s name has changed
</p>
</li>
<li>
<p>
<code>restored</code> – the workspace&#8217;s layout has changed to a previously saved layout
</p>
</li>
<li>
<p>
<code>urgent</code> – the workspace has become urgent or lost its urgent status
</p>
</li>
</ul></div>
<div class="paragraph"><p>A <code>current (object)</code> property will be present with the affected workspace
whenever the type of event affects a workspace (otherwise, it will be <code>null</code>).</p></div>
<div class="paragraph"><p>When the change is "focus", an <code>old (object)</code> property will be present with the
previous workspace.  When the first switch occurs (when i3 focuses the
workspace visible at the beginning) there is no previous workspace, and the
<code>old</code> property will be set to <code>null</code>.  Also note that if the previous is empty
it will get destroyed when switching, but will still be present in the "old"
property.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "change": "focus",
 "current": {
  "id": 28489712,
  "type": "workspace",
  ...
 }
 "old": {
  "id": 28489715,
  "type": "workspace",
  ...
 }
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_output_event">5.4. output event</h3>
<div class="paragraph"><p>This event consists of a single serialized map containing a property
<code>change (string)</code> which indicates the type of the change (currently only
"unspecified").</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{ "change": "unspecified" }</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_mode_event">5.5. mode event</h3>
<div class="paragraph"><p>This event consists of a single serialized map containing a property
<code>change (string)</code> which holds the name of current mode in use. The name
is the same as specified in config when creating a mode. The default
mode is simply named default. It contains a second property, <code>pango_markup</code>, which
defines whether pango markup shall be used for displaying this mode.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
  "change": "default",
  "pango_markup": true
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_window_event">5.6. window event</h3>
<div class="paragraph"><p>This event consists of a single serialized map containing a property
<code>change (string)</code> which indicates the type of the change</p></div>
<div class="ulist"><ul>
<li>
<p>
<code>new</code> – the window has become managed by i3
</p>
</li>
<li>
<p>
<code>close</code> – the window has closed
</p>
</li>
<li>
<p>
<code>focus</code> – the window has received input focus
</p>
</li>
<li>
<p>
<code>title</code> – the window&#8217;s title has changed
</p>
</li>
<li>
<p>
<code>fullscreen_mode</code> – the window has entered or exited fullscreen mode
</p>
</li>
<li>
<p>
<code>move</code> – the window has changed its position in the tree
</p>
</li>
<li>
<p>
<code>floating</code> – the window has transitioned to or from floating
</p>
</li>
<li>
<p>
<code>urgent</code> – the window has become urgent or lost its urgent status
</p>
</li>
<li>
<p>
<code>mark</code> – a mark has been added to or removed from the window
</p>
</li>
</ul></div>
<div class="paragraph"><p>Additionally a <code>container (object)</code> field will be present, which consists
of the window&#8217;s parent container. Be aware that for the "new" event, the
container will hold the initial name of the newly reparented window (e.g.
if you run urxvt with a shell that changes the title, you will still at
this point get the window title as "urxvt").</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "change": "new",
 "container": {
  "id": 35569536,
  "type": "con",
  ...
 }
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_barconfig_update_event">5.7. barconfig_update event</h3>
<div class="paragraph"><p>This event consists of a single serialized map reporting on options from the
barconfig of the specified bar_id that were updated in i3. This event is the
same as a <code>GET_BAR_CONFIG</code> reply for the bar with the given id.</p></div>
</div>
<div class="sect2">
<h3 id="_binding_event">5.8. binding event</h3>
<div class="paragraph"><p>This event consists of a single serialized map reporting on the details of a
binding that ran a command because of user input. The <code>change (string)</code> field
indicates what sort of binding event was triggered (right now it will always be
<code>"run"</code> but may be expanded in the future).</p></div>
<div class="paragraph"><p>The <code>mode (string)</code> field contains the name of the mode the binding was run in.</p></div>
<div class="paragraph"><p>The <code>binding (object)</code> field contains details about the binding that was run:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
command (string)
</dt>
<dd>
<p>
        The i3 command that is configured to run for this binding.
</p>
</dd>
<dt class="hdlist1">
event_state_mask (array of strings)
</dt>
<dd>
<p>
        The group and modifier keys that were configured with this binding.
</p>
</dd>
<dt class="hdlist1">
input_code (integer)
</dt>
<dd>
<p>
        If the binding was configured with <code>bindcode</code>, this will be the key code
        that was given for the binding. If the binding is a mouse binding, it will be
        the number of the mouse button that was pressed. Otherwise it will be 0.
</p>
</dd>
<dt class="hdlist1">
symbol (string or null)
</dt>
<dd>
<p>
        If this is a keyboard binding that was configured with <code>bindsym</code>, this
        field will contain the given symbol. Otherwise it will be <code>null</code>.
</p>
</dd>
<dt class="hdlist1">
input_type (string)
</dt>
<dd>
<p>
        This will be <code>"keyboard"</code> or <code>"mouse"</code> depending on whether or not this was
        a keyboard or a mouse binding.
</p>
</dd>
</dl></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "change": "run",
 "binding": {
  "command": "nop",
  "event_state_mask": [
    "shift",
    "ctrl"
  ],
  "input_code": 0,
  "symbol": "t",
  "input_type": "keyboard"
 }
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_shutdown_event">5.9. shutdown event</h3>
<div class="paragraph"><p>This event is triggered when the connection to the ipc is about to shutdown
because of a user action such as a <code>restart</code> or <code>exit</code> command. The <code>change
(string)</code> field indicates why the ipc is shutting down. It can be either
<code>"restart"</code> or <code>"exit"</code>.</p></div>
<div class="paragraph"><p><strong>Example:</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "change": "restart"
}</code></pre>
</div></div>
</div>
<div class="sect2">
<h3 id="_tick_event">5.10. tick event</h3>
<div class="paragraph"><p>This event is triggered by a subscription to tick events or by a <code>SEND_TICK</code>
message.</p></div>
<div class="paragraph"><p><strong>Example (upon subscription):</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "first": true,
 "payload": ""
}</code></pre>
</div></div>
<div class="paragraph"><p><strong>Example (upon <code>SEND_TICK</code> with a payload of <code>arbitrary string</code>):</strong></p></div>
<div class="listingblock">
<div class="content">
<pre><code>{
 "first": false,
 "payload": "arbitrary string"
}</code></pre>
</div></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_see_also_existing_libraries">6. See also (existing libraries)</h2>
<div class="sectionbody">
<div class="paragraph" id="libraries"><p>For some languages, libraries are available (so you don’t have to implement
all this on your own). This list names some (if you wrote one, please let me
know):</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
C
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
i3 includes a headerfile <code>i3/ipc.h</code> which provides you all constants.
</p>
</li>
<li>
<p>
<a href="https://github.com/acrisci/i3ipc-glib">https://github.com/acrisci/i3ipc-glib</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
C++
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/Iskustvo/i3-ipcpp">i3-ipc++</a>
</p>
</li>
<li>
<p>
<a href="https://github.com/drmgc/i3ipcpp">https://github.com/drmgc/i3ipcpp</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
Go
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/mdirkse/i3ipc-go">https://github.com/mdirkse/i3ipc-go</a>
</p>
</li>
<li>
<p>
<a href="https://github.com/i3/go-i3">https://github.com/i3/go-i3</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
JavaScript
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/acrisci/i3ipc-gjs">https://github.com/acrisci/i3ipc-gjs</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
Lua
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/acrisci/i3ipc-lua">https://github.com/acrisci/i3ipc-lua</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
Perl
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://metacpan.org/module/AnyEvent::I3">https://metacpan.org/module/AnyEvent::I3</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
Python
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/acrisci/i3ipc-python">https://github.com/acrisci/i3ipc-python</a>
</p>
</li>
<li>
<p>
<a href="https://github.com/whitelynx/i3ipc">https://github.com/whitelynx/i3ipc</a> (not maintained)
</p>
</li>
<li>
<p>
<a href="https://github.com/ziberna/i3-py">https://github.com/ziberna/i3-py</a> (not maintained)
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
Ruby
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/veelenga/i3ipc-ruby">https://github.com/veelenga/i3ipc-ruby</a>
</p>
</li>
<li>
<p>
<a href="https://github.com/badboy/i3-ipc">https://github.com/badboy/i3-ipc</a> (not maintained)
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
Rust
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/tmerr/i3ipc-rs">https://github.com/tmerr/i3ipc-rs</a>
</p>
</li>
</ul></div>
</dd>
<dt class="hdlist1">
OCaml
</dt>
<dd>
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/Armael/ocaml-i3ipc">https://github.com/Armael/ocaml-i3ipc</a>
</p>
</li>
</ul></div>
</dd>
</dl></div>
</div>
</div>
<div class="sect1">
<h2 id="_appendix_a_detecting_byte_order_in_memory_safe_languages">7. Appendix A: Detecting byte order in memory-safe languages</h2>
<div class="sectionbody">
<div class="paragraph"><p>Some programming languages such as Go don’t offer a way to serialize data in the
native byte order of the machine they’re running on without resorting to tricks
involving the <code>unsafe</code> package.</p></div>
<div class="paragraph"><p>The following technique can be used (and will not be broken by changes to i3) to
detect the byte order i3 is using:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
The byte order dependent fields of an IPC message are message type and
   payload length.
</p>
<div class="ulist"><ul>
<li>
<p>
The message type <code>RUN_COMMAND</code> (0) is the same in big and little endian, so
     we can use it in either byte order to elicit a reply from i3.
</p>
</li>
<li>
<p>
The payload length 65536 + 256 (<code>0x00 01 01 00</code>) is the same in big and
     little endian, and also small enough to not worry about memory allocations
     of that size. We must use payloads of length 65536 + 256 in every message
     we send, so that i3 will be able to read the entire message regardless of
     the byte order it uses.
</p>
</li>
</ul></div>
</li>
<li>
<p>
Send a big endian encoded message of type <code>SUBSCRIBE</code> (2) with payload <code>[]</code>
   followed by 65536 + 256 - 2 <code>SPACE</code> (ASCII 0x20) bytes.
</p>
<div class="ulist"><ul>
<li>
<p>
If i3 is running in big endian, this message is treated as a noop,
     resulting in a <code>SUBSCRIBE</code> reply with payload <code>{"success":true}</code>
     <span class="footnote"><br />[A small payload is important: that way, we circumvent dealing
     with UNIX domain socket buffer sizes, whose size depends on the
     implementation/operating system. Exhausting such a buffer results in an i3
     deadlock unless you concurrently read and write, which — depending on the
     programming language — makes the technique much more complicated.]<br /></span>.
</p>
</li>
<li>
<p>
If i3 is running in little endian, this message is read in its entirety due
     to the byte order independent payload length, then
     <a href="https://github.com/i3/i3/blob/d726d09d496577d1c337a4b97486f2c9fbc914f1/src/ipc.c#L1188">silently
     discarded</a> due to the unknown message type.
</p>
</li>
</ul></div>
</li>
<li>
<p>
Send a byte order independent message, i.e. type <code>RUN_COMMAND</code> (0) with
   payload <code>nop byte order detection. padding:</code>, padded to 65536 + 256 bytes
   with <code>a</code> (ASCII 0x61) bytes. i3 will reply to this message with a reply of
   type <code>COMMAND</code> (0).
</p>
<div class="ulist"><ul>
<li>
<p>
The human-readable prefix is in there to not confuse readers of the i3 log.
</p>
</li>
<li>
<p>
This messages serves as a synchronization primitive so that we know whether
     i3 discarded the <code>SUBSCRIBE</code> message or didn’t answer it yet.
</p>
</li>
</ul></div>
</li>
<li>
<p>
Receive a message header from i3, decoding the message type as big endian.
</p>
<div class="ulist"><ul>
<li>
<p>
If the message’s reply type is <code>COMMAND</code> (0), i3 is running in little
     endian (because the <code>SUBSCRIBE</code> message was discarded). Decode the message
     payload length as little endian, receive the message payload.
</p>
</li>
<li>
<p>
If the message’s reply type is anything else, i3 is running in big endian
     (because our big endian encoded <code>SUBSCRIBE</code> message was answered). Decode
     the message payload length in big endian, receive the message
     payload. Then, receive the pending <code>COMMAND</code> message reply in big endian.
</p>
</li>
</ul></div>
</li>
<li>
<p>
From here on out, send/receive all messages using the detected byte order.
</p>
</li>
</ol></div>
<div class="paragraph"><p>Find an example implementation of this technique in
<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>
</div>
</div>
</div>
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
Last updated
 1980-01-01 00:00:00 UTC
</div>
</div>
</body>
</html>