diff options
-rw-r--r-- | include/sway/criteria.h | 1 | ||||
-rw-r--r-- | sway/criteria.c | 18 | ||||
-rw-r--r-- | sway/sway.5.scd | 5 |
3 files changed, 24 insertions, 0 deletions
diff --git a/include/sway/criteria.h b/include/sway/criteria.h index 74da132c..bd3ca0ac 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h | |||
@@ -18,6 +18,7 @@ struct criteria { | |||
18 | char *target; // workspace or output name for `assign` criteria | 18 | char *target; // workspace or output name for `assign` criteria |
19 | 19 | ||
20 | pcre *title; | 20 | pcre *title; |
21 | pcre *shell; | ||
21 | pcre *app_id; | 22 | pcre *app_id; |
22 | pcre *class; | 23 | pcre *class; |
23 | pcre *instance; | 24 | pcre *instance; |
diff --git a/sway/criteria.c b/sway/criteria.c index 4295cacc..9317a180 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | bool criteria_is_empty(struct criteria *criteria) { | 14 | bool criteria_is_empty(struct criteria *criteria) { |
15 | return !criteria->title | 15 | return !criteria->title |
16 | && !criteria->shell | ||
16 | && !criteria->app_id | 17 | && !criteria->app_id |
17 | && !criteria->class | 18 | && !criteria->class |
18 | && !criteria->instance | 19 | && !criteria->instance |
@@ -29,6 +30,7 @@ bool criteria_is_empty(struct criteria *criteria) { | |||
29 | 30 | ||
30 | void criteria_destroy(struct criteria *criteria) { | 31 | void criteria_destroy(struct criteria *criteria) { |
31 | pcre_free(criteria->title); | 32 | pcre_free(criteria->title); |
33 | pcre_free(criteria->shell); | ||
32 | pcre_free(criteria->app_id); | 34 | pcre_free(criteria->app_id); |
33 | pcre_free(criteria->class); | 35 | pcre_free(criteria->class); |
34 | pcre_free(criteria->instance); | 36 | pcre_free(criteria->instance); |
@@ -53,6 +55,13 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
53 | } | 55 | } |
54 | } | 56 | } |
55 | 57 | ||
58 | if (criteria->shell) { | ||
59 | const char *shell = view_get_type(view); | ||
60 | if (!shell || regex_cmp(shell, criteria->shell) != 0) { | ||
61 | return false; | ||
62 | } | ||
63 | } | ||
64 | |||
56 | if (criteria->app_id) { | 65 | if (criteria->app_id) { |
57 | const char *app_id = view_get_app_id(view); | 66 | const char *app_id = view_get_app_id(view); |
58 | if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) { | 67 | if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) { |
@@ -206,6 +215,7 @@ enum criteria_token { | |||
206 | T_FLOATING, | 215 | T_FLOATING, |
207 | T_ID, | 216 | T_ID, |
208 | T_INSTANCE, | 217 | T_INSTANCE, |
218 | T_SHELL, | ||
209 | T_TILING, | 219 | T_TILING, |
210 | T_TITLE, | 220 | T_TITLE, |
211 | T_URGENT, | 221 | T_URGENT, |
@@ -229,6 +239,8 @@ static enum criteria_token token_from_name(char *name) { | |||
229 | return T_ID; | 239 | return T_ID; |
230 | } else if (strcmp(name, "instance") == 0) { | 240 | } else if (strcmp(name, "instance") == 0) { |
231 | return T_INSTANCE; | 241 | return T_INSTANCE; |
242 | } else if (strcmp(name, "shell") == 0) { | ||
243 | return T_SHELL; | ||
232 | } else if (strcmp(name, "title") == 0) { | 244 | } else if (strcmp(name, "title") == 0) { |
233 | return T_TITLE; | 245 | return T_TITLE; |
234 | } else if (strcmp(name, "urgent") == 0) { | 246 | } else if (strcmp(name, "urgent") == 0) { |
@@ -271,6 +283,9 @@ static char *get_focused_prop(enum criteria_token token) { | |||
271 | case T_INSTANCE: | 283 | case T_INSTANCE: |
272 | value = view_get_instance(view); | 284 | value = view_get_instance(view); |
273 | break; | 285 | break; |
286 | case T_SHELL: | ||
287 | value = view_get_type(view); | ||
288 | break; | ||
274 | case T_TITLE: | 289 | case T_TITLE: |
275 | value = view_get_class(view); | 290 | value = view_get_class(view); |
276 | break; | 291 | break; |
@@ -332,6 +347,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { | |||
332 | case T_TITLE: | 347 | case T_TITLE: |
333 | generate_regex(&criteria->title, effective_value); | 348 | generate_regex(&criteria->title, effective_value); |
334 | break; | 349 | break; |
350 | case T_SHELL: | ||
351 | generate_regex(&criteria->shell, effective_value); | ||
352 | break; | ||
335 | case T_APP_ID: | 353 | case T_APP_ID: |
336 | generate_regex(&criteria->app_id, effective_value); | 354 | generate_regex(&criteria->app_id, effective_value); |
337 | break; | 355 | break; |
diff --git a/sway/sway.5.scd b/sway/sway.5.scd index ff138562..8d1cb8a1 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -551,6 +551,11 @@ The following attributes may be matched with: | |||
551 | value is \_\_focused\_\_, then the window instance must be the same as that | 551 | value is \_\_focused\_\_, then the window instance must be the same as that |
552 | of the currently focused window. | 552 | of the currently focused window. |
553 | 553 | ||
554 | *shell* | ||
555 | Compare value against the window shell, such as "xdg\_shell" or "xwayland". | ||
556 | Can be a regular expression. If value is \_\_focused\_\_, then the shell | ||
557 | must be the same as that of the currently focused window. | ||
558 | |||
554 | *tiling* | 559 | *tiling* |
555 | Matches tiling windows. | 560 | Matches tiling windows. |
556 | 561 | ||