Skip to content

Commit 78df8a7

Browse files
authored
Merge pull request #12 from typester/feature/bitop
feat: add tagList option
2 parents 3ea2120 + 138546a commit 78df8a7

File tree

2 files changed

+276
-101
lines changed

2 files changed

+276
-101
lines changed

README.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,78 @@ Example query:
4343
```graphql
4444
{
4545
outputs {
46-
outputId
4746
name
4847
focusedTags
4948
viewTags
5049
urgentTags
5150
layoutName
5251
}
53-
seatFocusedOutput { outputId name }
52+
seatFocusedOutput { name }
53+
}
54+
```
55+
56+
Fetch a single output by name when you only care about one:
57+
58+
```graphql
59+
query ($name: String!, $tagList: Boolean = true) {
60+
output(name: $name, tagList: $tagList) {
61+
name
62+
focusedTags
63+
focusedTagsList
64+
layoutName
65+
}
5466
}
5567
```
5668

5769
Subscription example:
5870

5971
```graphql
6072
subscription {
61-
riverEvents {
73+
events {
6274
__typename
63-
... on OutputFocusedTags { outputId name tags }
64-
... on SeatFocusedOutput { outputId name }
75+
... on OutputFocusedTags { name tags }
76+
... on SeatFocusedOutput { name }
6577
}
6678
}
6779
```
6880

69-
### WebSocket Client Mode
7081

71-
### Client mode
82+
## Working with Tag Lists
83+
84+
By default RiverQL exposes tag bitmasks as river does. Some environments — notably [eww](https://elkowar.github.io/eww/)
85+
struggle with bit operations, so any query or subscription can opt into decoded
86+
lists by passing `tagList: true`.
87+
When enabled, `focusedTagsList` / `urgentTagsList` fields become non-null while
88+
the original mask fields remain available for backward compatibility.
89+
90+
```graphql
91+
query ($tagList: Boolean = true) {
92+
outputs(tagList: $tagList) {
93+
name
94+
focusedTags
95+
focusedTagsList
96+
urgentTags
97+
urgentTagsList
98+
}
99+
}
100+
```
101+
102+
```graphql
103+
subscription ($name: String!, $tagList: Boolean = true) {
104+
eventsForOutput(outputName: $name, tagList: $tagList) {
105+
__typename
106+
... on OutputFocusedTags { name tags tagsList }
107+
}
108+
}
109+
```
110+
111+
### Client Mode
72112

73113
When a widget or script (for example an eww widget) needs data, invoke `riverql`
74114
without `--server`:
75115

76116
```bash
77-
riverql 'subscription { riverEvents { __typename } }'
117+
riverql 'subscription { events { __typename } }'
78118
```
79119

80120
Key points:
@@ -94,7 +134,7 @@ Polling a query:
94134

95135
```clojure
96136
(defpoll river_outputs :interval "5s"
97-
"riverql 'query { outputs { outputId name focusedTags } }' | jq -c '.data.outputs'")
137+
"riverql 'query { outputs { name focusedTags } }' | jq --unbuffered -c '.data.outputs'")
98138

99139
(defwidget river-tags []
100140
(box :orientation "vertical"
@@ -107,12 +147,12 @@ Polling a query:
107147
Listening for live events:
108148

109149
```clojure
110-
(deflisten river_events :initial "{}"
111-
"riverql 'subscription { riverEvents { __typename ... on OutputFocusedTags { outputId name tags } } }' | jq -c '.data.riverEvents'")
150+
(deflisten events :initial "{}"
151+
"riverql 'subscription { events { __typename ... on OutputFocusedTags { name tags } } }' | jq --unbuffered -c '.data.events'")
112152

113153
(defwidget river-event-feed []
114154
(box :orientation "vertical"
115-
(label :text (format "Latest event: %s" river_events))))
155+
(label :text (format "Latest event: %s" events))))
116156
```
117157

118158
`defpoll` is ideal for periodic snapshots (e.g. populating a list of outputs),

0 commit comments

Comments
 (0)