8 bool parse_bool(char *value, bool *b)
10 if (streq("true", value) || streq("on", value)) {
13 } else if (streq("false", value) || streq("off", value)) {
20 bool parse_split_type(char *s, split_type_t *t)
22 if (streq("horizontal", s)) {
25 } else if (streq("vertical", s)) {
32 bool parse_split_mode(char *s, split_mode_t *m)
34 if (streq("automatic", s)) {
37 } else if (streq("vertical", s)) {
44 bool parse_layout(char *s, layout_t *l)
46 if (streq("monocle", s)) {
49 } else if (streq("tiled", s)) {
56 bool parse_client_state(char *s, client_state_t *t)
58 if (streq("tiled", s)) {
61 } else if (streq("pseudo_tiled", s)) {
62 *t = STATE_PSEUDO_TILED;
64 } else if (streq("floating", s)) {
67 } else if (streq("fullscreen", s)) {
68 *t = STATE_FULLSCREEN;
74 bool parse_stack_layer(char *s, stack_layer_t *l)
76 if (streq("below", s)) {
79 } else if (streq("normal", s)) {
82 } else if (streq("above", s)) {
89 bool parse_direction(char *s, direction_t *d)
91 if (streq("north", s)) {
94 } else if (streq("west", s)) {
97 } else if (streq("south", s)) {
100 } else if (streq("east", s)) {
107 bool parse_cycle_direction(char *s, cycle_dir_t *d)
109 if (streq("next", s)) {
112 } else if (streq("prev", s)) {
119 bool parse_circulate_direction(char *s, circulate_dir_t *d)
121 if (streq("forward", s)) {
122 *d = CIRCULATE_FORWARD;
124 } else if (streq("backward", s)) {
125 *d = CIRCULATE_BACKWARD;
131 bool parse_history_direction(char *s, history_dir_t *d)
133 if (streq("older", s)) {
136 } else if (streq("newer", s)) {
144 bool parse_flip(char *s, flip_t *f)
146 if (streq("horizontal", s)) {
147 *f = FLIP_HORIZONTAL;
149 } else if (streq("vertical", s)) {
156 bool parse_pointer_action(char *s, pointer_action_t *a)
158 if (streq("move", s)) {
161 } else if (streq("resize_corner", s)) {
162 *a = ACTION_RESIZE_CORNER;
164 } else if (streq("resize_side", s)) {
165 *a = ACTION_RESIZE_SIDE;
167 } else if (streq("focus", s)) {
174 bool parse_child_polarity(char *s, child_polarity_t *p)
176 if (streq("first_child", s)) {
179 } else if (streq("second_child", s)) {
186 bool parse_degree(char *s, int *d)
201 bool parse_id(char *s, uint32_t *id)
205 uint32_t v = strtol(s, &end, 0);
206 if (errno != 0 || *end != '\0') {
213 bool parse_bool_declaration(char *s, char **key, bool *value, alter_state_t *state)
215 *key = strtok(s, EQL_TOK);
216 char *v = strtok(NULL, EQL_TOK);
218 *state = ALTER_TOGGLE;
221 if (parse_bool(v, value)) {
231 bool parse_index(char *s, uint16_t *idx)
233 return (sscanf(s, "^%hu", idx) == 1);
236 bool parse_rectangle(char *s, xcb_rectangle_t *r)
240 if (sscanf(s, "%hux%hu+%hi+%hi", &w, &h, &x, &y) != 4) {
250 bool parse_subscriber_mask(char *s, subscriber_mask_t *mask)
252 if (streq("all", s)) {
253 *mask = SBSC_MASK_ALL;
254 } else if (streq("node", s)) {
255 *mask = SBSC_MASK_NODE;
256 } else if (streq("desktop", s)) {
257 *mask = SBSC_MASK_DESKTOP;
258 } else if (streq("monitor", s)) {
259 *mask = SBSC_MASK_MONITOR;
260 } else if (streq("node_manage", s)) {
261 *mask = SBSC_MASK_NODE_MANAGE;
262 } else if (streq("node_unmanage", s)) {
263 *mask = SBSC_MASK_NODE_UNMANAGE;
264 } else if (streq("node_swap", s)) {
265 *mask = SBSC_MASK_NODE_SWAP;
266 } else if (streq("node_transfer", s)) {
267 *mask = SBSC_MASK_NODE_TRANSFER;
268 } else if (streq("node_focus", s)) {
269 *mask = SBSC_MASK_NODE_FOCUS;
270 } else if (streq("node_presel", s)) {
271 *mask = SBSC_MASK_NODE_PRESEL;
272 } else if (streq("node_stack", s)) {
273 *mask = SBSC_MASK_NODE_STACK;
274 } else if (streq("node_activate", s)) {
275 *mask = SBSC_MASK_NODE_ACTIVATE;
276 } else if (streq("node_geometry", s)) {
277 *mask = SBSC_MASK_NODE_GEOMETRY;
278 } else if (streq("node_state", s)) {
279 *mask = SBSC_MASK_NODE_STATE;
280 } else if (streq("node_flag", s)) {
281 *mask = SBSC_MASK_NODE_FLAG;
282 } else if (streq("node_layer", s)) {
283 *mask = SBSC_MASK_NODE_LAYER;
284 } else if (streq("desktop_add", s)) {
285 *mask = SBSC_MASK_DESKTOP_ADD;
286 } else if (streq("desktop_rename", s)) {
287 *mask = SBSC_MASK_DESKTOP_RENAME;
288 } else if (streq("desktop_remove", s)) {
289 *mask = SBSC_MASK_DESKTOP_REMOVE;
290 } else if (streq("desktop_swap", s)) {
291 *mask = SBSC_MASK_DESKTOP_SWAP;
292 } else if (streq("desktop_transfer", s)) {
293 *mask = SBSC_MASK_DESKTOP_TRANSFER;
294 } else if (streq("desktop_focus", s)) {
295 *mask = SBSC_MASK_DESKTOP_FOCUS;
296 } else if (streq("desktop_activate", s)) {
297 *mask = SBSC_MASK_DESKTOP_ACTIVATE;
298 } else if (streq("desktop_layout", s)) {
299 *mask = SBSC_MASK_DESKTOP_LAYOUT;
300 } else if (streq("monitor_add", s)) {
301 *mask = SBSC_MASK_MONITOR_ADD;
302 } else if (streq("monitor_rename", s)) {
303 *mask = SBSC_MASK_MONITOR_RENAME;
304 } else if (streq("monitor_remove", s)) {
305 *mask = SBSC_MASK_MONITOR_REMOVE;
306 } else if (streq("monitor_swap", s)) {
307 *mask = SBSC_MASK_MONITOR_SWAP;
308 } else if (streq("monitor_focus", s)) {
309 *mask = SBSC_MASK_MONITOR_FOCUS;
310 } else if (streq("monitor_geometry", s)) {
311 *mask = SBSC_MASK_MONITOR_GEOMETRY;
312 } else if (streq("report", s)) {
313 *mask = SBSC_MASK_REPORT;
322 } else if (streq(#k, tok)) { \
323 sel->k = OPTION_TRUE; \
324 } else if (streq("!" #k, tok)) { \
325 sel->k = OPTION_FALSE;
327 bool parse_monitor_modifiers(char *desc, monitor_select_t *sel)
330 while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
333 if (streq("occupied", tok)) {
334 sel->occupied = OPTION_TRUE;
335 } else if (streq("!occupied", tok)) {
336 sel->occupied = OPTION_FALSE;
345 bool parse_desktop_modifiers(char *desc, desktop_select_t *sel)
348 while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
351 if (streq("occupied", tok)) {
352 sel->occupied = OPTION_TRUE;
353 } else if (streq("!occupied", tok)) {
354 sel->occupied = OPTION_FALSE;
366 bool parse_node_modifiers(char *desc, node_select_t *sel)
369 while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
372 if (streq("tiled", tok)) {
373 sel->tiled = OPTION_TRUE;
374 } else if (streq("!tiled", tok)) {
375 sel->tiled = OPTION_FALSE;
381 GET_MOD(pseudo_tiled)