1 2 module fullapi; 3 4 import i3ipc; 5 6 void main(string[] args) 7 { 8 /+ All convenience wrappers for synchronous requests. 9 + Warning: Each of these will open and close an eventless connection +/ 10 //writeln(i3ipc.execute("reload")); 11 { 12 writeln(i3ipc.workspaces); 13 writeln(i3ipc.outputs); 14 writeln(i3ipc.tree); 15 writeln(i3ipc.marks); 16 auto configuredBars = i3ipc.configuredBars; 17 writeln(configuredBars); 18 configuredBars.each!((configuredBar) => writeln(i3ipc.getBarConfig(configuredBar))); 19 writeln(i3ipc.version_); 20 } 21 22 /+ Use a thread-backed connection for events 23 + and a query connection for synchronous queries. +/ 24 auto query_c = i3ipc.connect!QueryConnection; 25 auto event_c = i3ipc.connect!ThreadedConnection; 26 27 /+ Subscribe a callback to each possible event +/ 28 event_c.subscribe!"Workspace"((change, current, old) => writeln(change, " ", current, " ", old)); 29 event_c.subscribe!"Output"((change) => writeln(change)); 30 event_c.subscribe!"Mode"((change, pango_markup) => writeln(change, " ", pango_markup)); 31 event_c.subscribe!"Window"((change, container) => writeln(change, " ", container)); 32 event_c.subscribe!"BarConfigUpdate"((barConfig) => writeln(barConfig)); 33 event_c.subscribe!"Binding"((change, binding) => writeln(change, " ", binding)); 34 35 /+ The same as the convenience wrappers above, only for an already open connection +/ 36 { 37 writeln(query_c.workspaces); 38 writeln(query_c.outputs); 39 writeln(query_c.tree); 40 writeln(query_c.marks); 41 auto configuredBars = query_c.configuredBars; 42 writeln(configuredBars); 43 configuredBars.each!((configuredBar) => writeln(query_c.getBarConfig(configuredBar))); 44 writeln(query_c.version_); 45 } 46 47 writeln("Connection open for approximately 3 seconds, please generate some i3 events!"); 48 /+ A thread-backed connection automatically dispatches events, 49 + this just delays program termination. 50 +/ 51 Thread.sleep(3.seconds); 52 } 53 54 import core.thread; 55 56 import std.algorithm; 57 import std.stdio;