diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2019-10-02 17:36:52 +1000 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-02-27 14:03:22 +0100 |
commit | 2045ac3472196d6839569bccd436cde45ef6ca61 (patch) | |
tree | 999ec63750a37f18a67f35307dc1d72c9ca2a87e | |
parent | Add support for wlr-output-power-management-unstable-v1 (diff) | |
download | sway-2045ac3472196d6839569bccd436cde45ef6ca61.tar.gz sway-2045ac3472196d6839569bccd436cde45ef6ca61.tar.zst sway-2045ac3472196d6839569bccd436cde45ef6ca61.zip |
Introduce pid criteria token
This can be used as a workaround to flag terminal windows as urgent when
commands are completed, until urgency is introduced in the Wayland
protocol.
Configure your shell to run `swaymsg "[pid=$PPID] urgent enable"` when
commands are completed, and use a terminal which uses one process per
window.
-rw-r--r-- | include/sway/criteria.h | 1 | ||||
-rw-r--r-- | sway/criteria.c | 18 | ||||
-rw-r--r-- | sway/sway.5.scd | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/include/sway/criteria.h b/include/sway/criteria.h index beb76d5f..ad8610cd 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h | |||
@@ -46,6 +46,7 @@ struct criteria { | |||
46 | bool tiling; | 46 | bool tiling; |
47 | char urgent; // 'l' for latest or 'o' for oldest | 47 | char urgent; // 'l' for latest or 'o' for oldest |
48 | struct pattern *workspace; | 48 | struct pattern *workspace; |
49 | pid_t pid; | ||
49 | }; | 50 | }; |
50 | 51 | ||
51 | bool criteria_is_empty(struct criteria *criteria); | 52 | bool criteria_is_empty(struct criteria *criteria); |
diff --git a/sway/criteria.c b/sway/criteria.c index 2c8e1644..02b04fc8 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -31,7 +31,8 @@ bool criteria_is_empty(struct criteria *criteria) { | |||
31 | && !criteria->floating | 31 | && !criteria->floating |
32 | && !criteria->tiling | 32 | && !criteria->tiling |
33 | && !criteria->urgent | 33 | && !criteria->urgent |
34 | && !criteria->workspace; | 34 | && !criteria->workspace |
35 | && !criteria->pid; | ||
35 | } | 36 | } |
36 | 37 | ||
37 | // The error pointer is used for parsing functions, and saves having to pass it | 38 | // The error pointer is used for parsing functions, and saves having to pass it |
@@ -370,6 +371,12 @@ static bool criteria_matches_view(struct criteria *criteria, | |||
370 | } | 371 | } |
371 | } | 372 | } |
372 | 373 | ||
374 | if (criteria->pid) { | ||
375 | if (criteria->pid != view->pid) { | ||
376 | return false; | ||
377 | } | ||
378 | } | ||
379 | |||
373 | return true; | 380 | return true; |
374 | } | 381 | } |
375 | 382 | ||
@@ -458,6 +465,7 @@ enum criteria_token { | |||
458 | T_TITLE, | 465 | T_TITLE, |
459 | T_URGENT, | 466 | T_URGENT, |
460 | T_WORKSPACE, | 467 | T_WORKSPACE, |
468 | T_PID, | ||
461 | 469 | ||
462 | T_INVALID, | 470 | T_INVALID, |
463 | }; | 471 | }; |
@@ -493,6 +501,8 @@ static enum criteria_token token_from_name(char *name) { | |||
493 | return T_TILING; | 501 | return T_TILING; |
494 | } else if (strcmp(name, "floating") == 0) { | 502 | } else if (strcmp(name, "floating") == 0) { |
495 | return T_FLOATING; | 503 | return T_FLOATING; |
504 | } else if (strcmp(name, "pid") == 0) { | ||
505 | return T_PID; | ||
496 | } | 506 | } |
497 | return T_INVALID; | 507 | return T_INVALID; |
498 | } | 508 | } |
@@ -587,6 +597,12 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { | |||
587 | case T_WORKSPACE: | 597 | case T_WORKSPACE: |
588 | pattern_create(&criteria->workspace, value); | 598 | pattern_create(&criteria->workspace, value); |
589 | break; | 599 | break; |
600 | case T_PID: | ||
601 | criteria->pid = strtoul(value, &endptr, 10); | ||
602 | if (*endptr != 0) { | ||
603 | error = strdup("The value for 'pid' should be numeric"); | ||
604 | } | ||
605 | break; | ||
590 | case T_INVALID: | 606 | case T_INVALID: |
591 | break; | 607 | break; |
592 | } | 608 | } |
diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 6b2ad1b1..ad5dacc8 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -850,6 +850,9 @@ The following attributes may be matched with: | |||
850 | value is \_\_focused\_\_, then the window instance must be the same as that | 850 | value is \_\_focused\_\_, then the window instance must be the same as that |
851 | of the currently focused window. | 851 | of the currently focused window. |
852 | 852 | ||
853 | *pid* | ||
854 | Compare value against the window's process ID. Must be numeric. | ||
855 | |||
853 | *shell* | 856 | *shell* |
854 | Compare value against the window shell, such as "xdg_shell" or "xwayland". | 857 | Compare value against the window shell, such as "xdg_shell" or "xwayland". |
855 | Can be a regular expression. If value is \_\_focused\_\_, then the shell | 858 | Can be a regular expression. If value is \_\_focused\_\_, then the shell |