1
0
Fork 0
forked from wry/wry

config: add app-id window criteria

This commit is contained in:
Julian Orth 2025-05-01 18:27:42 +02:00
parent 6ef7655dbd
commit da64166e82
13 changed files with 102 additions and 24 deletions

View file

@ -257,6 +257,8 @@ pub struct WindowMatch {
pub client: Option<ClientMatch>,
pub title: Option<String>,
pub title_regex: Option<String>,
pub app_id: Option<String>,
pub app_id_regex: Option<String>,
}
#[derive(Debug, Clone)]

View file

@ -44,27 +44,33 @@ impl Parser for WindowMatchParser<'_> {
table: &IndexMap<Spanned<String>, Spanned<Value>>,
) -> ParseResult<Self> {
let mut ext = Extractor::new(self.0, span, table);
let ((
name,
not_val,
all_val,
any_val,
exactly_val,
types_val,
client_val,
title,
title_regex,
),) = ext.extract(((
opt(str("name")),
opt(val("not")),
opt(arr("all")),
opt(arr("any")),
opt(val("exactly")),
opt(val("types")),
opt(val("client")),
opt(str("title")),
opt(str("title-regex")),
),))?;
let (
(
name,
not_val,
all_val,
any_val,
exactly_val,
types_val,
client_val,
title,
title_regex,
),
(app_id, app_id_regex),
) = ext.extract((
(
opt(str("name")),
opt(val("not")),
opt(arr("all")),
opt(arr("any")),
opt(val("exactly")),
opt(val("types")),
opt(val("client")),
opt(str("title")),
opt(str("title-regex")),
),
(opt(str("app-id")), opt(str("app-id-regex"))),
))?;
let mut not = None;
if let Some(value) = not_val {
not = Some(Box::new(value.parse(&mut WindowMatchParser(self.0))?));
@ -106,6 +112,8 @@ impl Parser for WindowMatchParser<'_> {
},
title: title.despan_into(),
title_regex: title_regex.despan_into(),
app_id: app_id.despan_into(),
app_id_regex: app_id_regex.despan_into(),
types,
client,
})

View file

@ -257,6 +257,8 @@ impl Rule for WindowRule {
}
value!(Title, title);
value!(TitleRegex, title_regex);
value!(AppId, app_id);
value!(AppIdRegex, app_id_regex);
Some(())
}