i3ipc/reply.rs
1//! Abstractions for the replies passed back from i3.
2
3use std::collections::HashMap;
4
5/// The outcome of a single command.
6#[derive(Debug)]
7pub struct CommandOutcome {
8 /// Whether the command was successful.
9 pub success: bool,
10 /// A human-readable error message.
11 pub error: Option<String>,
12}
13
14/// The reply to the `command` request.
15#[derive(Debug)]
16pub struct Command {
17 /// A list of `CommandOutcome` structs; one for each command that was parsed.
18 pub outcomes: Vec<CommandOutcome>,
19}
20
21/// A single workspace.
22#[derive(Debug)]
23pub struct Workspace {
24 /// The logical number of the workspace. Corresponds to the command to switch to this
25 /// workspace. For named workspaces, this will be -1.
26 pub num: i32,
27 /// The name of this workspace (by default num+1), as changed by the user.
28 pub name: String,
29 /// Whether this workspace is currently visible on an output (multiple workspaces can be
30 /// visible at the same time).
31 pub visible: bool,
32 /// Whether this workspace currently has the focus (only one workspace can have the focus
33 /// at the same time).
34 pub focused: bool,
35 /// Whether a window on this workspace has the "urgent" flag set.
36 pub urgent: bool,
37 /// The rectangle of this workspace (equals the rect of the output it is on), consists of
38 /// x, y, width, height.
39 pub rect: (i32, i32, i32, i32),
40 /// The video output this workspace is on (LVDS1, VGA1, …).
41 pub output: String,
42}
43
44/// The reply to the `get_workspaces` request.
45#[derive(Debug)]
46pub struct Workspaces {
47 /// A list of workspaces.
48 pub workspaces: Vec<Workspace>,
49}
50
51/// The reply to the `subscribe` request.
52#[derive(Debug)]
53pub struct Subscribe {
54 /// Indicates whether the subscription was successful (the default) or whether a JSON
55 /// parse error occurred.
56 pub success: bool,
57}
58
59/// A single output (display)
60#[derive(Debug)]
61pub struct Output {
62 /// The name of this output (as seen in xrandr).
63 pub name: String,
64 /// Whether the output is currently active (has a valid mode).
65 pub active: bool,
66 /// Whether the output is currently the primary output.
67 pub primary: bool,
68 /// The name of the current workspace that is visible on this output. None if the output is
69 /// not active.
70 pub current_workspace: Option<String>,
71 /// The rectangle of this output (equals the rect of the output it is on), consists of
72 /// x, y, width, height.
73 pub rect: (i32, i32, i32, i32),
74}
75
76/// The reply to the `get_outputs` request.
77#[derive(Debug)]
78pub struct Outputs {
79 /// A list of outputs (displays)
80 pub outputs: Vec<Output>,
81}
82
83#[derive(Eq, PartialEq, Debug, Hash, Clone)]
84pub enum WindowProperty {
85 Title,
86 Instance,
87 Class,
88 WindowRole,
89 TransientFor,
90}
91
92#[derive(Eq, PartialEq, Debug, Clone)]
93pub enum NodeType {
94 Root,
95 Output,
96 Con,
97 FloatingCon,
98 Workspace,
99 DockArea,
100 /// A NodeType we don't support yet.
101 Unknown,
102}
103
104#[derive(Eq, PartialEq, Debug, Clone)]
105pub enum NodeBorder {
106 Normal,
107 None,
108 Pixel,
109 /// A NodeBorder we don't support yet.
110 Unknown,
111}
112
113#[derive(Eq, PartialEq, Debug, Clone)]
114pub enum NodeLayout {
115 SplitH,
116 SplitV,
117 Stacked,
118 Tabbed,
119 DockArea,
120 Output,
121 /// A NodeLayout we don't support yet.
122 Unknown,
123}
124
125/// The reply to the `get_tree` request.
126#[derive(Debug, Clone)]
127pub struct Node {
128 /// List of child node IDs (see `nodes`, `floating_nodes` and `id`) in focus order. Traversing
129 /// the tree by following the first entry in this array will result in eventually reaching the
130 /// one node with `focused` set to true.
131 pub focus: Vec<i64>,
132
133 /// The child nodes of this container.
134 pub nodes: Vec<Node>,
135
136 /// The child floating nodes of this container.
137 pub floating_nodes: Vec<Node>,
138
139 /// The internal ID (actually a C pointer value) of this container. Do not make any
140 /// assumptions about it. You can use it to (re-)identify and address containers when
141 /// talking to i3.
142 pub id: i64,
143
144 /// The internal name of this container. For all containers which are part of the tree
145 /// structure down to the workspace contents, this is set to a nice human-readable name of
146 /// the container. For containers that have an X11 window, the content is the title
147 /// (_NET_WM_NAME property) of that window. For all other containers, the content is not
148 /// defined (yet).
149 pub name: Option<String>,
150
151 /// Type of this container. Can be one of "root", "output", "con", "floating_con",
152 /// "workspace" or "dockarea".
153 pub nodetype: NodeType,
154
155 /// Can be either "normal", "none" or "1pixel", dependending on the container’s border
156 /// style.
157 pub border: NodeBorder,
158
159 /// Number of pixels of the border width.
160 pub current_border_width: i32,
161
162 /// Can be either "splith", "splitv", "stacked", "tabbed", "dockarea" or "output". Other values
163 /// might be possible in the future, should we add new layouts.
164 pub layout: NodeLayout,
165
166 /// The percentage which this container takes in its parent. A value of null means that the
167 /// percent property does not make sense for this container, for example for the root
168 /// container.
169 pub percent: Option<f64>,
170
171 /// The (x, y, width, height) absolute display coordinates for this container. Display
172 /// coordinates means that when you have two 1600x1200 monitors on a single X11 Display
173 /// (the standard way), the coordinates of the first window on the second monitor are
174 /// (1600, 0, 1600, 1200).
175 pub rect: (i32, i32, i32, i32),
176
177 /// The (x, y, width, height) coordinates of the actual client window inside its container.
178 /// These coordinates are relative to the container and do not include the window
179 /// decoration (which is actually rendered on the parent container). So for example, when
180 /// using the default layout, you will have a 2 pixel border on each side, making the
181 /// window_rect (2, 0, 632, 366).
182 pub window_rect: (i32, i32, i32, i32),
183
184 /// The (x, y, width, height) coordinates of the window decoration inside its container.
185 /// These coordinates are relative to the container and do not include the actual client
186 /// window.
187 pub deco_rect: (i32, i32, i32, i32),
188
189 /// The original geometry the window specified when i3 mapped it. Used when switching a
190 /// window to floating mode, for example.
191 pub geometry: (i32, i32, i32, i32),
192
193 /// The X11 window ID of the actual client window inside this container. This field is set
194 /// to null for split containers or otherwise empty containers. This ID corresponds to what
195 /// xwininfo(1) and other X11-related tools display (usually in hex).
196 pub window: Option<i32>,
197
198 /// X11 window properties title, instance, class, window_role and transient_for.
199 pub window_properties: Option<HashMap<WindowProperty, String>>,
200
201 /// Whether this container (window, split container, floating container or workspace) has the
202 /// urgency hint set, directly or indirectly. All parent containers up until the workspace
203 /// container will be marked urgent if they have at least one urgent child.
204 pub urgent: bool,
205
206 /// Whether this container is currently focused.
207 pub focused: bool,
208}
209
210/// The reply to the `get_marks` request.
211///
212/// Consists of a single vector of strings for each container that has a mark. A mark can only
213/// be set on one container, so the vector is unique. The order of that vector is undefined. If
214/// no window has a mark the response will be an empty vector.
215#[derive(Debug)]
216pub struct Marks {
217 pub marks: Vec<String>,
218}
219
220/// The reply to the `get_bar_ids` request.
221///
222/// This can be used by third-party workspace bars (especially i3bar, but others are free to
223/// implement compatible alternatives) to get the bar block configuration from i3.
224#[derive(Debug)]
225pub struct BarIds {
226 /// A vector of configured bar IDs.
227 pub ids: Vec<String>,
228}
229
230#[derive(Hash, Eq, PartialEq, Debug)]
231pub enum ColorableBarPart {
232 /// Background color of the bar.
233 Background,
234
235 /// Text color to be used for the statusline.
236 Statusline,
237
238 /// Text color to be used for the separator.
239 Separator,
240
241 /// Background color of the bar on the currently focused monitor output.
242 #[cfg(feature = "i3-4-12")]
243 #[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
244 FocusedBackground,
245
246 /// Text color to be used for the statusline on the currently focused
247 /// monitor output.
248 #[cfg(feature = "i3-4-12")]
249 #[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
250 FocusedStatusline,
251
252 /// Text color to be used for the separator on the currently focused
253 /// monitor output.
254 #[cfg(feature = "i3-4-12")]
255 #[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
256 FocusedSeparator,
257
258 /// Text color for a workspace button when the workspace has focus.
259 FocusedWorkspaceText,
260
261 /// Background color for a workspace button when the workspace has focus.
262 FocusedWorkspaceBg,
263
264 /// Border color for a workspace button when the workspace has focus.
265 FocusedWorkspaceBorder,
266
267 /// Text color for a workspace button when the workspace is active (visible) on some
268 /// output, but the focus is on another one. You can only tell this apart from the
269 /// focused workspace when you are using multiple monitors.
270 ActiveWorkspaceText,
271
272 /// Background color for a workspace button when the workspace is active (visible) on some
273 /// output, but the focus is on another one. You can only tell this apart from the
274 /// focused workspace when you are using multiple monitors.
275 ActiveWorkspaceBg,
276
277 /// Border color for a workspace button when the workspace is active (visible) on some
278 /// output, but the focus is on another one. You can only tell this apart from the
279 /// focused workspace when you are using multiple monitors.
280 ActiveWorkspaceBorder,
281
282 /// Text color for a workspace button when the workspace does not have focus and is not
283 /// active (visible) on any output. This will be the case for most workspaces.
284 InactiveWorkspaceText,
285
286 /// Background color for a workspace button when the workspace does not have focus and is
287 /// not active (visible) on any output. This will be the case for most workspaces.
288 InactiveWorkspaceBg,
289
290 /// Border color for a workspace button when the workspace does not have focus and is
291 /// not active (visible) on any output. This will be the case for most workspaces.
292 InactiveWorkspaceBorder,
293
294 /// Text color for workspaces which contain at least one window with the urgency hint set.
295 UrgentWorkspaceText,
296
297 /// Background color for workspaces which contain at least one window with the urgency hint
298 /// set.
299 UrgentWorkspaceBg,
300
301 /// Border color for workspaces which contain at least one window with the urgency hint set.
302 UrgentWorkspaceBorder,
303
304 /// Text color for the binding mode indicator.
305 BindingModeText,
306
307 /// Background color for the binding mode indicator.
308 BindingModeBg,
309
310 /// Border color for the binding mode indicator.
311 BindingModeBorder,
312
313 /// A ColorableBarPart we don't support yet.
314 Unknown,
315}
316
317/// The reply to the `get_bar_config` request.
318///
319/// This can be used by third-party workspace bars (especially i3bar, but others are free to
320/// implement compatible alternatives) to get the bar block configuration from i3.
321#[derive(Debug)]
322pub struct BarConfig {
323 /// The ID for this bar. Included in case you request multiple configurations and want to
324 /// differentiate the different replies.
325 pub id: String,
326
327 /// Either dock (the bar sets the dock window type) or hide (the bar does not show unless a
328 /// specific key is pressed).
329 pub mode: String,
330
331 /// Either bottom or top at the moment.
332 pub position: String,
333
334 /// Command which will be run to generate a statusline. Each line on stdout of this command
335 /// will be displayed in the bar. At the moment, no formatting is supported.
336 pub status_command: String,
337
338 /// The font to use for text on the bar.
339 pub font: String,
340
341 /// Display workspace buttons or not? Defaults to true.
342 pub workspace_buttons: bool,
343
344 /// Display the mode indicator or not? Defaults to true.
345 pub binding_mode_indicator: bool,
346
347 /// Should the bar enable verbose output for debugging? Defaults to false.
348 pub verbose: bool,
349
350 /// Contains key/value pairs of colors. Each value is a color code in hex, formatted
351 /// \#rrggbb (like in HTML).
352 pub colors: HashMap<ColorableBarPart, String>,
353}
354
355/// The reply to the `get_version` request.
356#[derive(Debug)]
357pub struct Version {
358 /// The major version of i3, such as 4.
359 pub major: i32,
360
361 /// The minor version of i3, such as 2. Changes in the IPC interface (new features) will
362 /// only occur with new minor (or major) releases. However, bugfixes might be introduced in
363 /// patch releases, too.
364 pub minor: i32,
365
366 /// The patch version of i3, such as 1 (when the complete version is 4.2.1). For versions
367 /// such as 4.2, patch will be set to 0.
368 pub patch: i32,
369
370 /// A human-readable version of i3 containing the precise git version, build date and
371 /// branch name. When you need to display the i3 version to your users, use the
372 /// human-readable version whenever possible (since this is what i3 --version displays,
373 /// too).
374 pub human_readable: String,
375
376 /// The current config path.
377 pub loaded_config_file_name: String,
378}
379
380/// The reply to the `get_binding_modes` request.
381#[cfg(feature = "i3-4-13")]
382#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-13")))]
383#[derive(Debug)]
384pub struct BindingModes {
385 /// A vector of all currently configured binding modes.
386 pub modes: Vec<String>,
387}
388
389/// The reply to the `get_config` request.
390#[cfg(feature = "i3-4-14")]
391#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
392#[derive(Debug)]
393pub struct Config {
394 /// A string containing the config file as loaded by i3 most recently.
395 pub config: String,
396}