aboutsummaryrefslogtreecommitdiff
path: root/sway/criteria.c
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-05-27 14:14:46 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-05-27 22:02:00 +1000
commit484cc189e909e6b8df42e80386e0335d6d317a6e (patch)
tree330c3cc22d7ca4d2773c208bd1f72e79b6f19c47 /sway/criteria.c
parent0c4b7907a01890730ad35a963da511d1008d9533 (diff)
Add shell criteria token
Closes #2044.
Diffstat (limited to 'sway/criteria.c')
-rw-r--r--sway/criteria.c18
1 files changed, 18 insertions, 0 deletions
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 @@
bool criteria_is_empty(struct criteria *criteria) {
return !criteria->title
+ && !criteria->shell
&& !criteria->app_id
&& !criteria->class
&& !criteria->instance
@@ -29,6 +30,7 @@ bool criteria_is_empty(struct criteria *criteria) {
void criteria_destroy(struct criteria *criteria) {
pcre_free(criteria->title);
+ pcre_free(criteria->shell);
pcre_free(criteria->app_id);
pcre_free(criteria->class);
pcre_free(criteria->instance);
@@ -53,6 +55,13 @@ static bool criteria_matches_view(struct criteria *criteria,
}
}
+ if (criteria->shell) {
+ const char *shell = view_get_type(view);
+ if (!shell || regex_cmp(shell, criteria->shell) != 0) {
+ return false;
+ }
+ }
+
if (criteria->app_id) {
const char *app_id = view_get_app_id(view);
if (!app_id || regex_cmp(app_id, criteria->app_id) != 0) {
@@ -206,6 +215,7 @@ enum criteria_token {
T_FLOATING,
T_ID,
T_INSTANCE,
+ T_SHELL,
T_TILING,
T_TITLE,
T_URGENT,
@@ -229,6 +239,8 @@ static enum criteria_token token_from_name(char *name) {
return T_ID;
} else if (strcmp(name, "instance") == 0) {
return T_INSTANCE;
+ } else if (strcmp(name, "shell") == 0) {
+ return T_SHELL;
} else if (strcmp(name, "title") == 0) {
return T_TITLE;
} else if (strcmp(name, "urgent") == 0) {
@@ -271,6 +283,9 @@ static char *get_focused_prop(enum criteria_token token) {
case T_INSTANCE:
value = view_get_instance(view);
break;
+ case T_SHELL:
+ value = view_get_type(view);
+ break;
case T_TITLE:
value = view_get_class(view);
break;
@@ -332,6 +347,9 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
case T_TITLE:
generate_regex(&criteria->title, effective_value);
break;
+ case T_SHELL:
+ generate_regex(&criteria->shell, effective_value);
+ break;
case T_APP_ID:
generate_regex(&criteria->app_id, effective_value);
break;