i3ipc_jl/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#[cfg(feature = "sway-1-1")]
60#[derive(Debug)]
61/// A mode for sway
62pub struct Mode {
63 pub width: i32,
64 pub height: i32,
65 pub refresh: i32,
66}
67
68/// A single output (display)
69#[derive(Debug)]
70pub struct Output {
71 /// The name of this output (as seen in xrandr).
72 pub name: String,
73 #[cfg(feature = "sway-1-1")]
74 /// Make of the Output
75 pub make: String,
76 #[cfg(feature = "sway-1-1")]
77 /// Make of the Output
78 pub model: String,
79 #[cfg(feature = "sway-1-1")]
80 /// Make of the Output
81 pub serial: String,
82 /// Whether the output is currently active (has a valid mode).
83 pub active: bool,
84 #[cfg(feature = "sway-1-1")]
85 /// DPMS status of the output
86 pub dpms: bool,
87 /// Whether the output is currently the primary output.
88 pub primary: bool,
89 #[cfg(feature = "sway-1-1")]
90 /// Scale of the output
91 pub scale: Option<f64>,
92 #[cfg(feature = "sway-1-1")]
93 /// Subpixel hinting for the output
94 pub subpixel_hinting: Option<String>,
95 #[cfg(feature = "sway-1-1")]
96 /// Transform for the output
97 pub transform: Option<String>,
98 /// The name of the current workspace that is visible on this output. None if the output is
99 /// not active.
100 pub current_workspace: Option<String>,
101 #[cfg(feature = "sway-1-1")]
102 /// Modes for the output
103 pub modes: Vec<Mode>,
104 #[cfg(feature = "sway-1-1")]
105 /// current mode for the output
106 pub current_mode: Option<Mode>,
107 /// The rectangle of this output (equals the rect of the output it is on), consists of
108 /// x, y, width, height.
109 pub rect: (i32, i32, i32, i32),
110}
111
112/// The reply to the `get_outputs` request.
113#[derive(Debug)]
114pub struct Outputs {
115 /// A list of outputs (displays)
116 pub outputs: Vec<Output>,
117}
118
119#[derive(Eq, PartialEq, Debug, Hash, Clone)]
120pub enum WindowProperty {
121 Title,
122 Instance,
123 Class,
124 WindowRole,
125 TransientFor,
126 Machine,
127 Mark,
128}
129
130#[derive(Eq, PartialEq, Debug, Clone)]
131pub enum NodeType {
132 Root,
133 Output,
134 Con,
135 FloatingCon,
136 Workspace,
137 DockArea,
138 /// A NodeType we don't support yet.
139 Unknown,
140}
141
142#[derive(Eq, PartialEq, Debug, Clone)]
143pub enum NodeBorder {
144 Normal,
145 None,
146 Pixel,
147 /// A NodeBorder we don't support yet.
148 Unknown,
149}
150
151#[derive(Eq, PartialEq, Debug, Clone)]
152pub enum NodeLayout {
153 SplitH,
154 SplitV,
155 Stacked,
156 Tabbed,
157 DockArea,
158 Output,
159 /// A NodeLayout we don't support yet.
160 Unknown,
161}
162
163#[derive(Eq, PartialEq, Debug, Clone)]
164pub enum NodeFloating {
165 AutoOff,
166 AutoOn,
167 UserOff,
168 UserOn,
169 /// A NodeFloating we don't support yet.
170 Unknown,
171}
172
173#[derive(Eq, PartialEq, Debug, Clone)]
174pub enum NodeFullScreenMode {
175 None,
176 Fullscreen,
177 Global,
178 /// A NodeFullScreenMode we don't support yet.
179 Unknown,
180}
181
182/// The reply to the `get_tree` request.
183#[derive(Debug, Clone)]
184pub struct Node {
185 /// List of child node IDs (see `nodes`, `floating_nodes` and `id`) in focus order. Traversing
186 /// the tree by following the first entry in this array will result in eventually reaching the
187 /// one node with `focused` set to true.
188 pub focus: Vec<i64>,
189
190 /// The child nodes of this container.
191 pub nodes: Vec<Node>,
192
193 /// The child floating nodes of this container.
194 pub floating_nodes: Vec<Node>,
195
196 /// The internal ID (actually a C pointer value) of this container. Do not make any
197 /// assumptions about it. You can use it to (re-)identify and address containers when
198 /// talking to i3.
199 pub id: i64,
200
201 /// The internal name of this container. For all containers which are part of the tree
202 /// structure down to the workspace contents, this is set to a nice human-readable name of
203 /// the container. For containers that have an X11 window, the content is the title
204 /// (_NET_WM_NAME property) of that window. For all other containers, the content is not
205 /// defined (yet).
206 pub name: Option<String>,
207
208 /// Type of this container. Can be one of "root", "output", "con", "floating_con",
209 /// "workspace" or "dockarea".
210 pub nodetype: NodeType,
211
212 /// Can be either "normal", "none" or "1pixel", dependending on the container’s border
213 /// style.
214 pub border: NodeBorder,
215
216 /// Number of pixels of the border width.
217 pub current_border_width: i32,
218
219 /// Can be either "splith", "splitv", "stacked", "tabbed", "dockarea" or "output". Other values
220 /// might be possible in the future, should we add new layouts.
221 pub layout: NodeLayout,
222
223 /// The percentage which this container takes in its parent. A value of null means that the
224 /// percent property does not make sense for this container, for example for the root
225 /// container.
226 pub percent: Option<f64>,
227
228 /// The (x, y, width, height) absolute display coordinates for this container. Display
229 /// coordinates means that when you have two 1600x1200 monitors on a single X11 Display
230 /// (the standard way), the coordinates of the first window on the second monitor are
231 /// (1600, 0, 1600, 1200).
232 pub rect: (i32, i32, i32, i32),
233
234 /// The (x, y, width, height) coordinates of the actual client window inside its container.
235 /// These coordinates are relative to the container and do not include the window
236 /// decoration (which is actually rendered on the parent container). So for example, when
237 /// using the default layout, you will have a 2 pixel border on each side, making the
238 /// window_rect (2, 0, 632, 366).
239 pub window_rect: (i32, i32, i32, i32),
240
241 /// The (x, y, width, height) coordinates of the window decoration inside its container.
242 /// These coordinates are relative to the container and do not include the actual client
243 /// window.
244 pub deco_rect: (i32, i32, i32, i32),
245
246 /// The original geometry the window specified when i3 mapped it. Used when switching a
247 /// window to floating mode, for example.
248 pub geometry: (i32, i32, i32, i32),
249
250 /// The X11 window ID of the actual client window inside this container. This field is set
251 /// to null for split containers or otherwise empty containers. This ID corresponds to what
252 /// xwininfo(1) and other X11-related tools display (usually in hex).
253 pub window: Option<i32>,
254
255 /// X11 window properties title, instance, class, window_role and transient_for.
256 pub window_properties: Option<HashMap<WindowProperty, String>>,
257
258 /// Whether this container (window, split container, floating container or workspace) has the
259 /// urgency hint set, directly or indirectly. All parent containers up until the workspace
260 /// container will be marked urgent if they have at least one urgent child.
261 pub urgent: bool,
262
263 /// Whether this container is currently focused.
264 pub focused: bool,
265
266 /// List of marks assigned to container
267 pub marks: Vec<String>,
268
269 /// Whether this window is "sticky". If it is also floating, this window will be present on all workspaces on the
270 /// same output.
271 pub sticky: bool,
272
273 /// Whether this container is in fullscreen state or not.
274 pub fullscreen_mode: NodeFullScreenMode,
275
276 /// Floating state of container. Can be either "auto_on", "auto_off", "user_on" or "user_off"
277 pub floating: NodeFloating,
278}
279
280/// The reply to the `get_marks` request.
281///
282/// Consists of a single vector of strings for each container that has a mark. A mark can only
283/// be set on one container, so the vector is unique. The order of that vector is undefined. If
284/// no window has a mark the response will be an empty vector.
285#[derive(Debug)]
286pub struct Marks {
287 pub marks: Vec<String>,
288}
289
290/// The reply to the `get_bar_ids` request.
291///
292/// This can be used by third-party workspace bars (especially i3bar, but others are free to
293/// implement compatible alternatives) to get the bar block configuration from i3.
294#[derive(Debug)]
295pub struct BarIds {
296 /// A vector of configured bar IDs.
297 pub ids: Vec<String>,
298}
299
300#[derive(Hash, Eq, PartialEq, Debug)]
301pub enum ColorableBarPart {
302 /// Background color of the bar.
303 Background,
304
305 /// Text color to be used for the statusline.
306 Statusline,
307
308 /// Text color to be used for the separator.
309 Separator,
310
311 /// Background color of the bar on the currently focused monitor output.
312 #[cfg(feature = "i3-4-12")]
313 #[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
314 FocusedBackground,
315
316 /// Text color to be used for the statusline on the currently focused
317 /// monitor output.
318 #[cfg(feature = "i3-4-12")]
319 #[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
320 FocusedStatusline,
321
322 /// Text color to be used for the separator on the currently focused
323 /// monitor output.
324 #[cfg(feature = "i3-4-12")]
325 #[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
326 FocusedSeparator,
327
328 /// Text color for a workspace button when the workspace has focus.
329 FocusedWorkspaceText,
330
331 /// Background color for a workspace button when the workspace has focus.
332 FocusedWorkspaceBg,
333
334 /// Border color for a workspace button when the workspace has focus.
335 FocusedWorkspaceBorder,
336
337 /// Text color for a workspace button when the workspace is active (visible) on some
338 /// output, but the focus is on another one. You can only tell this apart from the
339 /// focused workspace when you are using multiple monitors.
340 ActiveWorkspaceText,
341
342 /// Background color for a workspace button when the workspace is active (visible) on some
343 /// output, but the focus is on another one. You can only tell this apart from the
344 /// focused workspace when you are using multiple monitors.
345 ActiveWorkspaceBg,
346
347 /// Border color for a workspace button when the workspace is active (visible) on some
348 /// output, but the focus is on another one. You can only tell this apart from the
349 /// focused workspace when you are using multiple monitors.
350 ActiveWorkspaceBorder,
351
352 /// Text color for a workspace button when the workspace does not have focus and is not
353 /// active (visible) on any output. This will be the case for most workspaces.
354 InactiveWorkspaceText,
355
356 /// Background color for a workspace button when the workspace does not have focus and is
357 /// not active (visible) on any output. This will be the case for most workspaces.
358 InactiveWorkspaceBg,
359
360 /// Border color for a workspace button when the workspace does not have focus and is
361 /// not active (visible) on any output. This will be the case for most workspaces.
362 InactiveWorkspaceBorder,
363
364 /// Text color for workspaces which contain at least one window with the urgency hint set.
365 UrgentWorkspaceText,
366
367 /// Background color for workspaces which contain at least one window with the urgency hint
368 /// set.
369 UrgentWorkspaceBg,
370
371 /// Border color for workspaces which contain at least one window with the urgency hint set.
372 UrgentWorkspaceBorder,
373
374 /// Text color for the binding mode indicator.
375 BindingModeText,
376
377 /// Background color for the binding mode indicator.
378 BindingModeBg,
379
380 /// Border color for the binding mode indicator.
381 BindingModeBorder,
382
383 /// A ColorableBarPart we don't support yet.
384 Unknown,
385}
386
387/// The reply to the `get_bar_config` request.
388///
389/// This can be used by third-party workspace bars (especially i3bar, but others are free to
390/// implement compatible alternatives) to get the bar block configuration from i3.
391#[derive(Debug)]
392pub struct BarConfig {
393 /// The ID for this bar. Included in case you request multiple configurations and want to
394 /// differentiate the different replies.
395 pub id: String,
396
397 /// Either dock (the bar sets the dock window type) or hide (the bar does not show unless a
398 /// specific key is pressed).
399 pub mode: String,
400
401 /// Either bottom or top at the moment.
402 pub position: String,
403
404 /// Command which will be run to generate a statusline. Each line on stdout of this command
405 /// will be displayed in the bar. At the moment, no formatting is supported.
406 pub status_command: String,
407
408 /// The font to use for text on the bar.
409 pub font: String,
410
411 /// Display workspace buttons or not? Defaults to true.
412 pub workspace_buttons: bool,
413
414 /// Display the mode indicator or not? Defaults to true.
415 pub binding_mode_indicator: bool,
416
417 /// Should the bar enable verbose output for debugging? Defaults to false.
418 pub verbose: bool,
419
420 /// Contains key/value pairs of colors. Each value is a color code in hex, formatted
421 /// \#rrggbb (like in HTML).
422 pub colors: HashMap<ColorableBarPart, String>,
423}
424
425/// The reply to the `get_version` request.
426#[derive(Debug)]
427pub struct Version {
428 /// The major version of i3, such as 4.
429 pub major: i32,
430
431 /// The minor version of i3, such as 2. Changes in the IPC interface (new features) will
432 /// only occur with new minor (or major) releases. However, bugfixes might be introduced in
433 /// patch releases, too.
434 pub minor: i32,
435
436 /// The patch version of i3, such as 1 (when the complete version is 4.2.1). For versions
437 /// such as 4.2, patch will be set to 0.
438 pub patch: i32,
439
440 /// A human-readable version of i3 containing the precise git version, build date and
441 /// branch name. When you need to display the i3 version to your users, use the
442 /// human-readable version whenever possible (since this is what i3 --version displays,
443 /// too).
444 pub human_readable: String,
445
446 /// The current config path.
447 pub loaded_config_file_name: String,
448}
449
450/// The reply to the `get_binding_modes` request.
451#[cfg(feature = "i3-4-13")]
452#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-13")))]
453#[derive(Debug)]
454pub struct BindingModes {
455 /// A vector of all currently configured binding modes.
456 pub modes: Vec<String>,
457}
458
459/// The reply to the `get_config` request.
460#[cfg(feature = "i3-4-14")]
461#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
462#[derive(Debug)]
463pub struct Config {
464 /// A string containing the config file as loaded by i3 most recently.
465 pub config: String,
466}