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
//! Convenience functions for the window functionality in xdotool.
use crate;
use crate;
use crateOptionVec;
use craterun;
use Output;
// TODO: implement the behave command
/// Search for window with titles, names or classes with a regular expression pattern.
/// The output is a list of X window identifiers.
/// The default options are `SearchOption::Name`, `SearchOption::Class` and `SearchOption::ClassName`.
///
/// # Options
///
/// - `SearchOption::Class` Match against the window class.
/// - `SearchOption::ClassName` Match against the window class name.
/// - `SearchOption::MaxDepth(i32)` Set the recursion/child search depth. Default is -1, meaning infinite. 0 means no depth, only root windows will be searched.
/// - `SearchOption::Name` Match against the window name. This is the same string that is displayed in the window title bar.
/// - `SearchOption::OnlyVisible` Show only visible windows in the results.
/// - `SearchOption::Pid(u32)` Match windows that belong to a specific process id.
/// - `SearchOption::Screen(u8)` Only match windows on a certain desktop. The default is to search all desktops.
/// - `SearchOption::Limit(32)` Stop searching after finding N matching windows.
/// - `SearchOption::Pid(u32)` Match windows that belong to a specific process id. The default is no search limit, which is equivalent to 0.
/// - `SearchOption::All` Require that all conditions are met.
/// - `SearchOption::Any` Match windows that match any condition. This is on by default.
/// - `SearchOption::Sync` Block until there are results.
///
/// # Examples
///
/// Search for window on desktop 2:
///
/// ```
/// # use xdotool::{window, option_vec, OptionVec};
/// # use xdotool::command::options;
/// let output = window::search("Firefox", option_vec![
/// options::SearchOption::Desktop(2),
/// ]);
/// println!("{}", String::from_utf8(output.stdout)?);
/// # Ok::<(), std::string::FromUtf8Error>(())
/// ```
/// Output the pid owning a given window. This requires effort from the application owning a window and my not work for all windows.
/// Output the name of a given window, also known as the title.
/// This is the text displayed in the window's title bar by your window manager.
/// Output the geometry (location and position) of a window.
/// The values include: `x`, `y`, `width`, `height` and `screen number`.
///
/// # Options
///
/// - `GetWindowGeometryOption::Shell` Output values suitable for `eval` in a shell.
/// Prints the window id of the currently focused window.
/// Set the window size of the given window.
///
///
/// Percentages are valid for `width` and `height`.
/// They are relative to the geometry of the screen the window is on.
///
/// # Options
///
/// - `WindowSizeOption::UseHints` Use window sizing hints to set width and height.
/// - `WindowSizeOption::Sync` Wait until the window is actually resized.
///
/// # Examples
///
/// Set a terminal to be 80x24 character:
///
/// ```
/// # use xdotool::{window, option_vec, OptionVec};
/// # use xdotool::command::options;
/// let output = window::set_window_size("terminal-id", "80", "24", option_vec![
/// options::WindowSizeOption::UseHints,
/// ]);
/// ```
///
/// Make a window full height but half width:
///
/// ```
/// # use xdotool::{window, option_vec, OptionVec};
/// # use xdotool::command::options;
/// let output = window::set_window_size("window-id", "50%", "100%", OptionVec::new());
/// ```
/// Move the window to the given position.
///
///
/// If the given x coordinate is literally 'x', then the window's current x position will be unchanged.
/// The same applies for 'y'.
/// Percentages are valid width and height.
/// They are relative to the geometry of the screen the window is on.
///
/// # Options
///
/// - `WindowMoveOption::Sync` Wait until the window is actually moved.
/// - `WindowMoveOption::Relative` Make movement relative to the current window position.
///
/// # Examples
///
/// Align window to the right of the screen:
///
/// ```
/// # use xdotool::{window, option_vec, OptionVec};
/// # use xdotool::command::options;
/// let output = window::move_window("window-id", "50%", "0", OptionVec::new());
/// ```
/// Focus a window (May be ignored by some window managers or programs).
///
/// Map a window. In X11 terminology, mapping a window means making it visible to the screen.
///
/// # Options
///
/// - `SyncOption::Sync` Wait until the window is actually mapped.
/// Minimize a window. In X11 terminology, this is called _iconify_
///
/// # Options
///
/// - `SyncOption::Sync` Wait until the window is actually minimized.
/// Raise the window to the top of the stack.
/// This may not work on all window managers.
/// Reparent a window. This moves the `source_window` to be a child of `destination_window`
/// Close a window. This action will destroy the window, but will not try to kill the client controlling it.
/// Kill a window. This action will destroy the window and kill the client controlling it.
/// Unmap a window, making it no longer appear on your screen.
///
/// # Options
///
/// - `SyncOption::Sync` Wait until the window is actually unmapped.
/// Set properties about a window.
///
/// # Options
///
/// - `SetWindowOption::Name(String)` Set window WM_NAME (usually the window title).
/// - `SetWindowOption::IconName(String)` Set window WM_ICON_NAME (usually the window title when minimized).
/// - `SetWindowOption::Role(String)` Set window WM_WINDOW_ROLE.
/// - `SetWindowOption::ClassName(String)` Set window class name (not to be confused with window class).
/// - `SetWindowOption::Class(String)` Set window class.
/// - `SetWindowOption::Urgency(u8)` Set window urgency. If the value is 1 the window will be marked urgent, and the window manager will somehow highlight it for user's attention. If the value is 0, the window will be marked non-urgent.
/// - `SetWindowOption::OverrideRedirect(String)` This value is a hint to the window manager for wether or not it should be managed.
///