mirror of
https://github.com/swaywm/sway.git
synced 2024-11-10 20:44:01 +01:00
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.
This commit is contained in:
parent
5ed01c861a
commit
2045ac3472
@ -46,6 +46,7 @@ struct criteria {
|
|||||||
bool tiling;
|
bool tiling;
|
||||||
char urgent; // 'l' for latest or 'o' for oldest
|
char urgent; // 'l' for latest or 'o' for oldest
|
||||||
struct pattern *workspace;
|
struct pattern *workspace;
|
||||||
|
pid_t pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool criteria_is_empty(struct criteria *criteria);
|
bool criteria_is_empty(struct criteria *criteria);
|
||||||
|
@ -31,7 +31,8 @@ bool criteria_is_empty(struct criteria *criteria) {
|
|||||||
&& !criteria->floating
|
&& !criteria->floating
|
||||||
&& !criteria->tiling
|
&& !criteria->tiling
|
||||||
&& !criteria->urgent
|
&& !criteria->urgent
|
||||||
&& !criteria->workspace;
|
&& !criteria->workspace
|
||||||
|
&& !criteria->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The error pointer is used for parsing functions, and saves having to pass it
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,6 +465,7 @@ enum criteria_token {
|
|||||||
T_TITLE,
|
T_TITLE,
|
||||||
T_URGENT,
|
T_URGENT,
|
||||||
T_WORKSPACE,
|
T_WORKSPACE,
|
||||||
|
T_PID,
|
||||||
|
|
||||||
T_INVALID,
|
T_INVALID,
|
||||||
};
|
};
|
||||||
@ -493,6 +501,8 @@ static enum criteria_token token_from_name(char *name) {
|
|||||||
return T_TILING;
|
return T_TILING;
|
||||||
} else if (strcmp(name, "floating") == 0) {
|
} else if (strcmp(name, "floating") == 0) {
|
||||||
return T_FLOATING;
|
return T_FLOATING;
|
||||||
|
} else if (strcmp(name, "pid") == 0) {
|
||||||
|
return T_PID;
|
||||||
}
|
}
|
||||||
return T_INVALID;
|
return T_INVALID;
|
||||||
}
|
}
|
||||||
@ -587,6 +597,12 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) {
|
|||||||
case T_WORKSPACE:
|
case T_WORKSPACE:
|
||||||
pattern_create(&criteria->workspace, value);
|
pattern_create(&criteria->workspace, value);
|
||||||
break;
|
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:
|
case T_INVALID:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -850,6 +850,9 @@ The following attributes may be matched with:
|
|||||||
value is \_\_focused\_\_, then the window instance must be the same as that
|
value is \_\_focused\_\_, then the window instance must be the same as that
|
||||||
of the currently focused window.
|
of the currently focused window.
|
||||||
|
|
||||||
|
*pid*
|
||||||
|
Compare value against the window's process ID. Must be numeric.
|
||||||
|
|
||||||
*shell*
|
*shell*
|
||||||
Compare value against the window shell, such as "xdg_shell" or "xwayland".
|
Compare value against the window shell, such as "xdg_shell" or "xwayland".
|
||||||
Can be a regular expression. If value is \_\_focused\_\_, then the shell
|
Can be a regular expression. If value is \_\_focused\_\_, then the shell
|
||||||
|
Loading…
Reference in New Issue
Block a user