eww icon indicating copy to clipboard operation
eww copied to clipboard

[FEATURE] Add way to listen to state changes in `eww state`

Open heartles opened this issue 2 years ago • 1 comments

Description of the requested feature

It would be helpful to add a way to listen to or monitor for changes in variables from the eww state command. Users could use this to implement external scripts that interface with eww. They could also use it to create derived variables whose value depends on the state of other variables, effectively resolving the use case for issues like #355 without the proposed (and rejected) configuration syntax change.

Proposed configuration syntax

No response

Additional context

When the user runs eww state --listen or eww state -l, it would start a process that listens for changes to the eww state, and outputs each updated state variable on a new line when it is changed. So, say, if I ran eww update myvar=2, then the listener process would spit out myvar: 2.

This could be used to create derived variables using a configuration like this:

(deflisten doubledvar `eww state --listen | grep -E "^myvar: " | sed 's/^myvar: //' | jq '. * 2'`)

Alternative flag names might be --follow/-f,--monitor/-m, or --watch/-w

heartles avatar Nov 25 '23 01:11 heartles

Adding this feature might be a complex change, since right now when client asks server for something the server always responds with a single blob of bytes, so the server would need to add support for multiple responses.

kzdnk avatar Jul 21 '25 17:07 kzdnk