mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-03 05:34:32 +01:00
feat(wm): application specific configuration
Rules for particular applications can be kept in files of their own, applications.json, which komorebi.json names with app_specific_configuration_path: one path or a list. The ignore, manage and floating rules of every application in a file are added to the lists the configuration's own rules go in, so a file can be shared or kept apart from the settings. A path with no file behind it is skipped with a warning, since one komorebi.json is meant to work on every platform and may name a file that only another platform has; a file that is there and is not an applications.json is an error. The titleless and tabbed rules of other platforms are read and do nothing. komorebic/applications.json is a start for Plasma: it floats the calculators, the screenshot tool, the authentication dialog and System Settings. A test opens the windows it names.
This commit is contained in:
1 parent
5eaa613f50
commit
ed34286bca
15 files changed
+564
-6
No files matched your search
@@ -669,6 +669,13 @@ first and applies it only when it parsed, so a file that is half written changes
|
||||
for the window manager that is running what the three steps do for one that starts, and tiles
|
||||
every monitor again.
|
||||
|
||||
`app_specific_configuration_path` names files of rules for particular applications, which
|
||||
[`StaticConfig`] reads after the rules of its own (`apply_globals`): the `ignore`, `manage` and
|
||||
`floating` rules of each application in each file are appended to the same lists, once each (a
|
||||
rule that is in the list already is not added again). A path with no file is skipped with a
|
||||
warning, since one `komorebi.json` may name a file that only another platform has; a file that is
|
||||
there and is not an applications.json is an error.
|
||||
|
||||
Three kinds of key reach the model. A **setting** of the window manager is a field of it
|
||||
([`WindowManager::resize_delta`] and the others). A **default** is a process-wide static that a
|
||||
monitor or a workspace falls back to when it has no value of its own: the paddings, the layout
|
||||
@@ -686,6 +693,8 @@ goes the other way, for `GenerateStaticConfig`.
|
||||
| A key komorebi does not read does not stop a configuration from loading | serde: [`StaticConfig`] ignores unknown keys, and a key of another platform is a field nothing reads | `the_keys_that_do_nothing_on_kde_are_accepted_and_ignored`, `fixtures_load_round_trip_and_only_lose_windows_only_keys` | none |
|
||||
| The keys the parity test ignores are keys `StaticConfig` does not read | test: the ignore lists are compared with the schema of [`StaticConfig`] | `the_lists_name_no_key_that_is_read` | none |
|
||||
| The example in the docs is the example file, which loads | test | `the_example_in_the_docs_is_the_example_file`, `fixtures_load_round_trip_and_only_lose_windows_only_keys` | none |
|
||||
| A path to an applications file that is not there is skipped, and one that is there and is broken is an error | framework path: `handle_asc_file` returns early when the path does not exist, and parses the file otherwise | `a_missing_application_specific_configuration_is_skipped_not_fatal`, `an_application_specific_configuration_that_exists_but_is_broken_is_still_an_error`, `a_file_that_is_not_there_is_skipped_and_one_that_is_broken_is_an_error` | none |
|
||||
| The rules of an applications file and of the configuration add up | framework path: both are appended to the process-wide lists | `the_rules_of_the_configuration_and_of_the_file_add_up`, `every_file_of_a_list_is_read` | none |
|
||||
| A file that cannot be read changes nothing | framework path: [`StaticConfig::reload`] reads and parses the file before it applies anything | `a_configuration_that_cannot_be_read_changes_nothing`, `the_daemon_follows_the_file_it_is_given_when_the_file_changes` | none |
|
||||
| The daemon applies a change to its file, written in place or replaced by a rename | framework path: the watcher sends `ReloadStaticConfiguration` to the daemon's own socket | `the_daemon_follows_the_file_it_is_given_when_the_file_changes`, `vm-module` | none: the file has to be the one the daemon was started with |
|
||||
| A monitor takes the entry its display index preference gives it, else the first nobody has | framework path: [`StaticConfig::postload`] and [`StaticConfig::reload`] choose the entry by serial number id first | `a_monitor_takes_the_configuration_its_display_index_preference_gives_it` | none |
|
||||
@@ -987,7 +996,9 @@ A window is shown, and ends up on a tile:
|
||||
with several monitors, [`komorebi/tests/hot_reload.rs`](../../komorebi/tests/hot_reload.rs) the
|
||||
daemon following a file, and
|
||||
[`komorebi/tests/config_parity.rs`](../../komorebi/tests/config_parity.rs) the files of other
|
||||
platforms and the example, which load.
|
||||
platforms and the example, which load; [`komorebi/tests/asc.rs`](../../komorebi/tests/asc.rs)
|
||||
the applications files; [`komorebi/src/core/asc.rs`](../../komorebi/src/core/asc.rs) their
|
||||
format.
|
||||
- [`komorebi/src/process_event.rs`](../../komorebi/src/process_event.rs): what each event
|
||||
does, and the thread that handles them.
|
||||
- [`komorebi/src/process_command.rs`](../../komorebi/src/process_command.rs): the socket, what
|
||||
|
||||
@@ -347,3 +347,10 @@ which do not exist here. The watcher is `hotwatch`, whose default is to wait two
|
||||
editor to settle. An editor either writes a file in place or replaces it with a new one, so the
|
||||
daemon reloads on a modification and on a removal, and the test that follows a real daemon
|
||||
through both of them is `the_daemon_follows_the_file_it_is_given_when_the_file_changes`.
|
||||
|
||||
## Why is an applications file that is not there skipped, and one that is broken an error?
|
||||
|
||||
Because one `komorebi.json` is meant to work on every platform, and the file it points to may be
|
||||
one that another platform has: a configuration written for macOS names `applications.mac.json`,
|
||||
which a KDE desktop does not have. The daemon warns and goes on. A file that exists and is not an
|
||||
applications.json is a mistake in something the user wrote, and is an error.
|
||||
@@ -12,6 +12,7 @@ different layout. This page has the file as it is:
|
||||
|
||||
```json
|
||||
{
|
||||
"app_specific_configuration_path": "$HOME/.config/komorebi/applications.json",
|
||||
"cross_monitor_move_behaviour": "Insert",
|
||||
"default_workspace_padding": 15,
|
||||
"default_container_padding": 15,
|
||||
@@ -67,6 +68,15 @@ with `komorebic start --config`. [Configuration](usage/configuration.md) explain
|
||||
where the daemon looks. The settings of a monitor with more than one entry in `monitors`, and of
|
||||
each workspace, are there too.
|
||||
|
||||
### Application specific configuration
|
||||
|
||||
`app_specific_configuration_path` names a file of rules for the applications that need them, which
|
||||
the repository has a start of in
|
||||
[`komorebic/applications.json`](../komorebic/applications.json). Put a copy where the example
|
||||
says, `~/.config/komorebi/applications.json`; a path with no file behind it is skipped.
|
||||
[Application specific configuration](usage/application-specific-configuration.md) explains the
|
||||
format.
|
||||
|
||||
### Padding
|
||||
|
||||
While you can set the workspace padding (the space between the outer edges of the windows and
|
||||
|
||||
+3
-2
@@ -51,8 +51,9 @@ float its windows.
|
||||
[Workspaces](usage/workspaces.md) explains how each monitor shows one of its workspaces, which
|
||||
are KWin's virtual desktops, and how to show another or move a window to one.
|
||||
[Configuration](usage/configuration.md) explains `komorebi.json`, where komorebi looks for it and
|
||||
how it is reloaded when it changes, and [Example configurations](example-configurations.md) has
|
||||
one to start from.
|
||||
how it is reloaded when it changes, [Example configurations](example-configurations.md) has one to
|
||||
start from, and [Application specific configuration](usage/application-specific-configuration.md)
|
||||
explains the files of rules for particular applications it can name.
|
||||
[Subscribing to notifications](usage/subscribing-to-notifications.md) explains how a program
|
||||
such as a status bar follows what komorebi does. The [CLI reference](cli/start.md) has a page
|
||||
for every `komorebic` command, generated from its help.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"app_specific_configuration_path": "$HOME/.config/komorebi/applications.json",
|
||||
"cross_monitor_move_behaviour": "Insert",
|
||||
"default_workspace_padding": 15,
|
||||
"default_container_padding": 15,
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Application specific configuration
|
||||
|
||||
Some applications need to be told how to behave under a tiling window manager: a calculator that
|
||||
should float instead of taking a tile, a launcher that should never be tiled. The
|
||||
[rules](rules.md) that say so can be put in `komorebi.json`, or in a file of their own,
|
||||
`applications.json`, that the configuration names. The file can be shared, or kept apart from
|
||||
the settings, and a list of files can be put together from several sources.
|
||||
|
||||
## The file
|
||||
|
||||
`applications.json` is an object with one entry for each application. The name of the entry is
|
||||
only for the reader. Each entry has lists of [rules](rules.md), as `komorebi.json` has them:
|
||||
|
||||
```json
|
||||
{
|
||||
"KDE Plasma": {
|
||||
"floating": [
|
||||
{ "kind": "Class", "id": "org.kde.kcalc", "matching_strategy": "Equals" },
|
||||
{ "kind": "Class", "id": "org.kde.spectacle", "matching_strategy": "Equals" }
|
||||
]
|
||||
},
|
||||
"Steam": {
|
||||
"ignore": [{ "kind": "Exe", "id": "steam", "matching_strategy": "Equals" }]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| List | What it does | In `komorebi.json` |
|
||||
|---|---|---|
|
||||
| `ignore` | komorebi leaves the windows alone | `ignore_rules` |
|
||||
| `manage` | komorebi tiles the windows, whatever the ignore rules say | `manage_rules` |
|
||||
| `floating` | the windows open floating | `floating_applications` |
|
||||
| `titleless`, `tabbed` | nothing: they work around how another platform exposes windows, and a KWin window is always a window | `titleless_applications`, `tabbed_applications` |
|
||||
|
||||
An entry named `$schema` has the address of a schema as its value, as an editor wants it, and
|
||||
is ignored.
|
||||
|
||||
## Naming the file
|
||||
|
||||
`app_specific_configuration_path` in `komorebi.json` is the path of one file, or a list of paths:
|
||||
|
||||
```json
|
||||
{
|
||||
"app_specific_configuration_path": "$HOME/.config/komorebi/applications.json"
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"app_specific_configuration_path": [
|
||||
"$HOME/.config/komorebi/applications.json",
|
||||
"$HOME/.config/komorebi/mine.json"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Environment variables in a path, such as `$HOME`, are replaced. The files are read when
|
||||
`komorebi.json` is: when the daemon starts, and again when the configuration changes. Their rules
|
||||
are added to the ones the daemon has, after the rules of `komorebi.json` itself, which
|
||||
[Configuration](configuration.md#rules) explains.
|
||||
|
||||
A path with no file behind it is skipped, and the daemon logs a warning: one `komorebi.json` can
|
||||
serve every platform, even if it names a file that only another platform has. A file that is
|
||||
there and is not an `applications.json`, or has a rule that is not valid, is an error: the daemon
|
||||
does not start with it, and a reload with it fails and logs the error. Only a file with the
|
||||
extension `.json` is read.
|
||||
|
||||
## The file komorebi ships
|
||||
|
||||
[`komorebic/applications.json`](../../komorebic/applications.json) in the repository has an
|
||||
entry for KDE Plasma, which floats the calculators of KDE and GNOME, the screenshot tool, the
|
||||
authentication dialog of Plasma and System Settings. A test loads it, and opens the windows it
|
||||
names.
|
||||
@@ -96,6 +96,7 @@ can have values of their own, which come before the default.
|
||||
| `ignore_rules` | Windows komorebi leaves alone (`float_rules` is the same key under its old name) |
|
||||
| `manage_rules` | Windows komorebi tiles whatever the ignore rules say |
|
||||
| `floating_applications` | Windows that open floating |
|
||||
| `app_specific_configuration_path` | One `applications.json`, or a list of them, whose rules are added to these ([Application specific configuration](application-specific-configuration.md)) |
|
||||
|
||||
Each is a list of rules, which [Rules](rules.md) explains. A rule is an object with `kind` (`Exe`,
|
||||
`Class`, `Title` or `Path`), `id` and `matching_strategy` (`Equals`, `StartsWith`, `EndsWith`,
|
||||
|
||||
Reference in new issue
Block a user