mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-04 05:56:31 +01:00
feat(wm): subscribe to notifications
A program such as a status bar has to follow the window manager, and so far it could only ask: komorebi on Windows and on macOS sends notifications for that. The daemon now keeps subscribers, each a Unix socket in its data directory that a program listens on, and after each event and each message it handles, it connects to every subscriber and writes the event or the message with the state after it. A subscriber can ask to be sent only what changed the state; a window that is shown and a new subscription are always sent, so a subscriber has the state as soon as it subscribes. A subscriber that cannot be connected to is dropped with its socket file and not tried again, and a stopping daemon closes an empty connection to each one. komorebic gains subscribe-socket and unsubscribe-socket, and komorebi-client subscribe and subscribe_with_options, which bind the socket and subscribe. The tests subscribe through real sockets against the fake desktop: a shown window is sent with the state that has it, a subscriber that filters is not sent a question that changed nothing, and one that is gone is dropped.
This commit is contained in:
1 parent
6f657e53e3
commit
e2d757bbb0
20 files changed
+1078
-25
No files matched your search
@@ -62,10 +62,12 @@ without a checkout of the toolchain.
|
||||
(`window_manager_event`, `window_manager_event_listener`, `process_event`), the
|
||||
`Ring` that holds monitors, workspaces and containers, and the lists in which
|
||||
some elements are locked in place. It answers the messages on the daemon's
|
||||
socket (`core::SocketMessage`, `process_command`) and shows its state
|
||||
(`state`).
|
||||
socket (`core::SocketMessage`, `process_command`), shows its state (`state`),
|
||||
and sends its subscribers a notification of each event and message it handles
|
||||
(`notify_subscribers`).
|
||||
- [`komorebi-client`](komorebi-client): a library that sends messages to the
|
||||
daemon and reads its answers, and re-exports the types they are made of.
|
||||
daemon, reads its answers, subscribes to its notifications, and re-exports
|
||||
the types they are made of.
|
||||
- [`komorebic`](komorebic): the command line. A subcommand that asks something
|
||||
of the daemon is one message on its socket; `start`, `log`, `data-directory`,
|
||||
`completions` and the hidden `docgen` work without the daemon.
|
||||
@@ -118,6 +120,11 @@ Everything else reaches the daemon as a message on its socket: one JSON
|
||||
`SocketMessage` per line, handled one at a time with the window manager
|
||||
locked. A message that asks a question is answered on the same connection.
|
||||
|
||||
A program such as a status bar can subscribe to the daemon's notifications: it
|
||||
listens on a socket of its own, and after each event and each message, the
|
||||
daemon connects to it and writes the event or the message with the state of
|
||||
the window manager.
|
||||
|
||||
## Documentation
|
||||
|
||||
The user guide starts at [`docs/index.md`](docs/index.md), and
|
||||
|
||||
Reference in new issue
Block a user