1
0
Fork 0
forked from wry/wry

config: add client-rule infrastructure

This commit is contained in:
Julian Orth 2025-05-04 18:02:17 +02:00
parent 17e715cde4
commit fd2163d658
32 changed files with 1804 additions and 27 deletions

View file

@ -500,6 +500,86 @@
}
]
},
"ClientMatch": {
"description": "Criteria for matching clients.\n\nIf no fields are set, all clients are matched. If multiple fields are set, all fields\nmust match the client.\n",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Matches if the client rule with this name matches.\n\n- Example:\n\n ```toml\n [[clients]]\n name = \"spotify\"\n match.sandbox-app-id = \"com.spotify.Client\"\n\n # Matches the same clients as the previous rule.\n [[clients]]\n match.name = \"spotify\"\n ```\n"
},
"not": {
"description": "Matches if the contained criteria don't match.\n\n- Example:\n\n ```toml\n [[clients]]\n name = \"not-spotify\"\n match.not.sandbox-app-id = \"com.spotify.Client\"\n ```\n",
"$ref": "#/$defs/ClientMatch"
},
"all": {
"type": "array",
"description": "Matches if all of the contained criteria match.\n\n- Example:\n\n ```toml\n [[clients]]\n match.all = [\n { sandbox-app-id = \"com.spotify.Client\" },\n { sandbox-engine = \"org.flatpak\" },\n ]\n ```\n",
"items": {
"description": "",
"$ref": "#/$defs/ClientMatch"
}
},
"any": {
"type": "array",
"description": "Matches if any of the contained criteria match.\n\n- Example:\n\n ```toml\n [[clients]]\n match.any = [\n { sandbox-app-id = \"com.spotify.Client\" },\n { sandbox-app-id = \"com.valvesoftware.Steam\" },\n ]\n ```\n",
"items": {
"description": "",
"$ref": "#/$defs/ClientMatch"
}
},
"exactly": {
"description": "Matches if a specific number of contained criteria match.\n\n- Example:\n\n ```toml\n # Matches any client that is either steam or sandboxed by flatpak but not both.\n [[clients]]\n match.exactly.num = 1\n match.exactly.list = [\n { sandbox-engine = \"org.flatpak\" },\n { sandbox-app-id = \"com.valvesoftware.Steam\" },\n ]\n ```\n",
"$ref": "#/$defs/ClientMatchExactly"
}
},
"required": []
},
"ClientMatchExactly": {
"description": "Criterion for matching a specific number of client criteria.\n",
"type": "object",
"properties": {
"num": {
"type": "number",
"description": "The number of criteria that must match."
},
"list": {
"type": "array",
"description": "The list of criteria.",
"items": {
"description": "",
"$ref": "#/$defs/ClientMatch"
}
}
},
"required": [
"num",
"list"
]
},
"ClientRule": {
"description": "A client rule.\n",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of this rule.\n\nThis name can be referenced in other rules.\n\n- Example\n\n ```toml\n [[clients]]\n name = \"spotify\"\n match.sandbox-app-id = \"com.spotify.Client\"\n\n [[clients]]\n match.name = \"spotify\"\n action = \"kill-client\"\n ```\n"
},
"match": {
"description": "The criteria that select the client that this rule applies to.",
"$ref": "#/$defs/ClientMatch"
},
"action": {
"description": "An action to execute when a client matches the criteria.",
"$ref": "#/$defs/Action"
},
"latch": {
"description": "An action to execute when a client no longer matches the criteria.",
"$ref": "#/$defs/Action"
}
},
"required": []
},
"Color": {
"type": "string",
"description": "A color.\n\nThe format should be one of the following:\n\n- `#rgb`\n- `#rrggbb`\n- `#rgba`\n- `#rrggbba`\n"
@ -714,6 +794,14 @@
"type": "integer",
"description": "The maximum call depth of named actions. This setting prevents infinite recursion\nwhen using named actions. Setting this value to 0 or less disables named actions\ncompletely. The default is `16`.\n",
"minimum": 0.0
},
"clients": {
"type": "array",
"description": "An array of client rules.\n\nThese rules can be used to give names to clients and to manipulate them.\n\n- Example:\n\n ```toml\n [[clients]]\n name = \"spotify\"\n match.sandbox-app-id = \"com.spotify.Client\"\n ```\n",
"items": {
"description": "",
"$ref": "#/$defs/ClientRule"
}
}
},
"required": []
@ -1384,7 +1472,8 @@
"toggle-float-above-fullscreen",
"pin-float",
"unpin-float",
"toggle-float-pinned"
"toggle-float-pinned",
"kill-client"
]
},
"Status": {

View file

@ -700,6 +700,171 @@ The string should have one of the following values:
The brightness in cd/m^2.
<a name="types-ClientMatch"></a>
### `ClientMatch`
Criteria for matching clients.
If no fields are set, all clients are matched. If multiple fields are set, all fields
must match the client.
Values of this type should be tables.
The table has the following fields:
- `name` (optional):
Matches if the client rule with this name matches.
- Example:
```toml
[[clients]]
name = "spotify"
match.sandbox-app-id = "com.spotify.Client"
# Matches the same clients as the previous rule.
[[clients]]
match.name = "spotify"
```
The value of this field should be a string.
- `not` (optional):
Matches if the contained criteria don't match.
- Example:
```toml
[[clients]]
name = "not-spotify"
match.not.sandbox-app-id = "com.spotify.Client"
```
The value of this field should be a [ClientMatch](#types-ClientMatch).
- `all` (optional):
Matches if all of the contained criteria match.
- Example:
```toml
[[clients]]
match.all = [
{ sandbox-app-id = "com.spotify.Client" },
{ sandbox-engine = "org.flatpak" },
]
```
The value of this field should be an array of [ClientMatchs](#types-ClientMatch).
- `any` (optional):
Matches if any of the contained criteria match.
- Example:
```toml
[[clients]]
match.any = [
{ sandbox-app-id = "com.spotify.Client" },
{ sandbox-app-id = "com.valvesoftware.Steam" },
]
```
The value of this field should be an array of [ClientMatchs](#types-ClientMatch).
- `exactly` (optional):
Matches if a specific number of contained criteria match.
- Example:
```toml
# Matches any client that is either steam or sandboxed by flatpak but not both.
[[clients]]
match.exactly.num = 1
match.exactly.list = [
{ sandbox-engine = "org.flatpak" },
{ sandbox-app-id = "com.valvesoftware.Steam" },
]
```
The value of this field should be a [ClientMatchExactly](#types-ClientMatchExactly).
<a name="types-ClientMatchExactly"></a>
### `ClientMatchExactly`
Criterion for matching a specific number of client criteria.
Values of this type should be tables.
The table has the following fields:
- `num` (required):
The number of criteria that must match.
The value of this field should be a number.
- `list` (required):
The list of criteria.
The value of this field should be an array of [ClientMatchs](#types-ClientMatch).
<a name="types-ClientRule"></a>
### `ClientRule`
A client rule.
Values of this type should be tables.
The table has the following fields:
- `name` (optional):
The name of this rule.
This name can be referenced in other rules.
- Example
```toml
[[clients]]
name = "spotify"
match.sandbox-app-id = "com.spotify.Client"
[[clients]]
match.name = "spotify"
action = "kill-client"
```
The value of this field should be a string.
- `match` (optional):
The criteria that select the client that this rule applies to.
The value of this field should be a [ClientMatch](#types-ClientMatch).
- `action` (optional):
An action to execute when a client matches the criteria.
The value of this field should be a [Action](#types-Action).
- `latch` (optional):
An action to execute when a client no longer matches the criteria.
The value of this field should be a [Action](#types-Action).
<a name="types-Color"></a>
### `Color`
@ -1417,6 +1582,22 @@ The table has the following fields:
The numbers should be greater than or equal to 0.
- `clients` (optional):
An array of client rules.
These rules can be used to give names to clients and to manipulate them.
- Example:
```toml
[[clients]]
name = "spotify"
match.sandbox-app-id = "com.spotify.Client"
```
The value of this field should be an array of [ClientRules](#types-ClientRule).
<a name="types-Connector"></a>
### `Connector`
@ -3129,6 +3310,12 @@ The string should have one of the following values:
Toggles whether the currently focused floating window is pinned.
- `kill-client`:
Kills a client.
This action has no effect outside of client rules.
<a name="types-Status"></a>

View file

@ -821,6 +821,11 @@ SimpleActionName:
- value: toggle-float-pinned
description: |
Toggles whether the currently focused floating window is pinned.
- value: kill-client
description: |
Kills a client.
This action has no effect outside of client rules.
Color:
@ -2487,6 +2492,23 @@ Config:
The maximum call depth of named actions. This setting prevents infinite recursion
when using named actions. Setting this value to 0 or less disables named actions
completely. The default is `16`.
clients:
kind: array
items:
ref: ClientRule
required: false
description: |
An array of client rules.
These rules can be used to give names to clients and to manipulate them.
- Example:
```toml
[[clients]]
name = "spotify"
match.sandbox-app-id = "com.spotify.Client"
```
Idle:
@ -3016,3 +3038,149 @@ Float:
The default is `false`.
kind: boolean
required: false
ClientRule:
kind: table
description: |
A client rule.
fields:
name:
kind: string
required: false
description: |
The name of this rule.
This name can be referenced in other rules.
- Example
```toml
[[clients]]
name = "spotify"
match.sandbox-app-id = "com.spotify.Client"
[[clients]]
match.name = "spotify"
action = "kill-client"
```
match:
ref: ClientMatch
required: false
description: The criteria that select the client that this rule applies to.
action:
ref: Action
required: false
description: An action to execute when a client matches the criteria.
latch:
ref: Action
required: false
description: An action to execute when a client no longer matches the criteria.
ClientMatch:
kind: table
description: |
Criteria for matching clients.
If no fields are set, all clients are matched. If multiple fields are set, all fields
must match the client.
fields:
name:
kind: string
required: false
description: |
Matches if the client rule with this name matches.
- Example:
```toml
[[clients]]
name = "spotify"
match.sandbox-app-id = "com.spotify.Client"
# Matches the same clients as the previous rule.
[[clients]]
match.name = "spotify"
```
not:
ref: ClientMatch
required: false
description: |
Matches if the contained criteria don't match.
- Example:
```toml
[[clients]]
name = "not-spotify"
match.not.sandbox-app-id = "com.spotify.Client"
```
all:
kind: array
items:
ref: ClientMatch
required: false
description: |
Matches if all of the contained criteria match.
- Example:
```toml
[[clients]]
match.all = [
{ sandbox-app-id = "com.spotify.Client" },
{ sandbox-engine = "org.flatpak" },
]
```
any:
kind: array
items:
ref: ClientMatch
required: false
description: |
Matches if any of the contained criteria match.
- Example:
```toml
[[clients]]
match.any = [
{ sandbox-app-id = "com.spotify.Client" },
{ sandbox-app-id = "com.valvesoftware.Steam" },
]
```
exactly:
ref: ClientMatchExactly
required: false
description: |
Matches if a specific number of contained criteria match.
- Example:
```toml
# Matches any client that is either steam or sandboxed by flatpak but not both.
[[clients]]
match.exactly.num = 1
match.exactly.list = [
{ sandbox-engine = "org.flatpak" },
{ sandbox-app-id = "com.valvesoftware.Steam" },
]
```
ClientMatchExactly:
kind: table
description: |
Criterion for matching a specific number of client criteria.
fields:
num:
kind: number
required: true
description: The number of criteria that must match.
list:
kind: array
items:
ref: ClientMatch
required: true
description: The list of criteria.