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 /sway | |
parent | 5ed01c861a2e720d53b42f707872dbfb36b2fce7 (diff) | |
download | sway-2045ac3472196d6839569bccd436cde45ef6ca61.tar.xz |
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.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/criteria.c | 18 | ||||
-rw-r--r-- | sway/sway.5.scd | 3 |
2 files changed, 20 insertions, 1 deletions
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) { && !criteria->floating && !criteria->tiling && !criteria->urgent - && !criteria->workspace; + && !criteria->workspace + && !criteria->pid; } // 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, } } + if (criteria->pid) { + if (criteria->pid != view->pid) { + return false; + } + } + return true; } @@ -458,6 +465,7 @@ enum criteria_token { T_TITLE, T_URGENT, T_WORKSPACE, + T_PID, T_INVALID, }; @@ -493,6 +501,8 @@ static enum criteria_token token_from_name(char *name) { return T_TILING; } else if (strcmp(name, "floating") == 0) { return T_FLOATING; + } else if (strcmp(name, "pid") == 0) { + return T_PID; } return T_INVALID; } @@ -587,6 +597,12 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { case T_WORKSPACE: pattern_create(&criteria->workspace, value); break; + case T_PID: + criteria->pid = strtoul(value, &endptr, 10); + if (*endptr != 0) { + error = strdup("The value for 'pid' should be numeric"); + } + break; case T_INVALID: break; } 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: value is \_\_focused\_\_, then the window instance must be the same as that of the currently focused window. +*pid* + Compare value against the window's process ID. Must be numeric. + *shell* Compare value against the window shell, such as "xdg_shell" or "xwayland". Can be a regular expression. If value is \_\_focused\_\_, then the shell |