Skip to content

Commit 8483381

Browse files
authored
Merge pull request #18 from typester/feature/eww-example
add eww example
2 parents c25e3b4 + 2053261 commit 8483381

4 files changed

Lines changed: 163 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ RiverQL exposes [River window manager](https://isaacfreund.com/software/river/)
44
It ships a server that bridges River's Wayland status protocol into GraphQL queries and
55
subscriptions, plus a CLI client for driving `graphql-transport-ws` streams.
66

7+
## Example Status Bar (eww + RiverQL)
8+
9+
`examples/eww` contains a ready-to-run setup that wires RiverQL into an
10+
[eww](https://elkowar.github.io/eww/) status bar. The example launches a snapshot
11+
poller for river outputs, reacts to live tag updates, and renders the result as a
12+
panel.
13+
14+
![eww status bar preview](examples/eww/eww-bar.png)
15+
16+
This indicates that:
17+
- Tags 1 and 3 are focused.
18+
- Tags 1, 2, 3, and 0 are currently occupied.
19+
- No urgent tags are present.
20+
21+
Try it by copying the directory into your own eww config (`~/.config/eww`) or
22+
by running `eww --config ./examples/eww open bar-window-1` inside the repository while the
23+
RiverQL server is running.
24+
25+
This example supports multiple monitors. Open `bar-window-1` for DP-1, `bar-window-2` for DP-2 respectively.
26+
If your environment has a different name e.g. eDP-1, you need to modify the code.
27+
728
## Features
829

930
- GraphQL access to River output/seat state (tags, layouts, focused view, mode)
@@ -26,6 +47,9 @@ Most setups launch the server inside River's init script:
2647
riverql --server &
2748
```
2849

50+
Note that you might need to set this with full executable path like: `~/.cargo/bin/riverql --server &`.
51+
52+
2953
By default this creates a Unix socket under `$XDG_RUNTIME_DIR/riverql.sock`. To
3054
override, use `--listen`, e.g. `riverql --server --listen tcp://127.0.0.1:8080`.
3155

examples/eww/eww-bar.png

2.83 KB
Loading

examples/eww/eww.scss

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
* {
2+
all: unset;
3+
font-family: "Terminess Nerd Font Propo";
4+
font-size: 12pt;
5+
}
6+
7+
.bar {
8+
margin: 0px;
9+
padding: 0px 0px;
10+
background-color: #1a1b26;
11+
12+
.bar-right {
13+
margin: 0 8px;
14+
}
15+
16+
.arch-logo {
17+
//color: #1793d0;
18+
margin-left: 6px;
19+
font-size: 16px;
20+
font-weight: normal;
21+
}
22+
23+
.taglist {
24+
margin-left: 20px;
25+
26+
.focused {
27+
background-color: #fefefe;
28+
29+
.tag-text {
30+
color: black;
31+
}
32+
33+
.occupied {
34+
border: 1px solid black;
35+
}
36+
}
37+
38+
.urgent {
39+
background-color: red;
40+
}
41+
42+
.occupied {
43+
margin-top: 2px;
44+
margin-left: 2px;
45+
border: 1px solid #ccc;
46+
}
47+
}
48+
49+
.focused_view {
50+
margin-left: 20px;
51+
}
52+
}

examples/eww/eww.yuck

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
(deflisten river-focused-view :initial "{}"
2+
"riverql 'subscription { events { ... on SeatFocusedView { title }}}'")
3+
4+
;; DP-1
5+
(deflisten river-view-tags-1 :initial "[]"
6+
`riverql 'subscription { eventsForOutput(outputName: "DP-1", tagList: true) { ... on OutputViewTags { tagsList }}}' | jq --unbuffered -c '[range(0;10) as $i | any(.data.eventsForOutput.tagsList[]; . == $i)]'`)
7+
8+
(deflisten river-focused-tags-1 :initial "[]"
9+
`riverql 'subscription { eventsForOutput(outputName: "DP-1", tagList: true) { ... on OutputFocusedTags { tagsList }}}' | jq --unbuffered -c '[range(0;10) as $i | any(.data.eventsForOutput.tagsList[]; . == $i)]'`)
10+
11+
(deflisten river-urgent-tags-1 :initial "[]"
12+
`riverql 'subscription { eventsForOutput(outputName: "DP-1", tagList: true) { ... on OutputUrgentTags { tagsList }}}' | jq --unbuffered -c '[range(0;10) as $i | any(.data.eventsForOutput.tagsList[]; . == $i)]'`)
13+
14+
;; DP-2
15+
(deflisten river-view-tags-2 :initial "[]"
16+
`riverql 'subscription { eventsForOutput(outputName: "DP-2", tagList: true) { ... on OutputViewTags { tagsList }}}' | jq --unbuffered -c '[range(0;10) as $i | any(.data.eventsForOutput.tagsList[]; . == $i)]'`)
17+
18+
(deflisten river-focused-tags-2 :initial "[]"
19+
`riverql 'subscription { eventsForOutput(outputName: "DP-2", tagList: true) { ... on OutputFocusedTags { tagsList }}}' | jq --unbuffered -c '[range(0;10) as $i | any(.data.eventsForOutput.tagsList[]; . == $i)]'`)
20+
21+
(deflisten river-urgent-tags-2 :initial "[]"
22+
`riverql 'subscription { eventsForOutput(outputName: "DP-2", tagList: true) { ... on OutputUrgentTags { tagsList }}}' | jq --unbuffered -c '[range(0;10) as $i | any(.data.eventsForOutput.tagsList[]; . == $i)]'`)
23+
24+
25+
26+
(defwidget focused-view []
27+
(label :text `${river-focused-view.data.events.title ?: ""}` :halign "start" :hexpand true :class "focused_view"))
28+
29+
(defwidget river-tags [focused-tags urgent-tags view-tags]
30+
(box :orientation "h" :spacing 10 :halign "start" :class "taglist"
31+
(for i in `[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]`
32+
(tag :index i
33+
:focused-tags focused-tags
34+
:urgent-tags urgent-tags
35+
:view-tags view-tags))))
36+
37+
(defwidget tag [index focused-tags urgent-tags view-tags]
38+
(box :class `${urgent-tags[index] ? "urgent" : focused-tags[index] ? "focused" : ""}`
39+
(overlay
40+
(box :width 32 :height 18)
41+
(literal :content `${view-tags[index] ?
42+
'(box :halign "start" :valign "start"
43+
(box :class "occupied" :width 7 :height 7))' : ""}`)
44+
(label :text `${index == 9 ? "0" : index + 1}` :class "tag-text"))))
45+
46+
(defwidget bar-left [focused-tags urgent-tags view-tags]
47+
(box :orientation "h" :halign "start" :hexpand true :space-evenly false
48+
(label :text "" :class "arch-logo")
49+
(river-tags :focused-tags focused-tags :urgent-tags urgent-tags :view-tags view-tags)
50+
(focused-view)))
51+
52+
(defwidget bar-right []
53+
(box :orientation "h" :halign "end" :class "bar-right"
54+
(systray :icon-size 16)))
55+
56+
(defwidget bar [focused-tags urgent-tags view-tags]
57+
(box :orientation "h" :space-evenly false :class "bar" :width: "100%"
58+
(bar-left :focused-tags focused-tags :urgent-tags urgent-tags :view-tags view-tags)
59+
(bar-right)))
60+
61+
(defwindow bar-window-1
62+
:monitor 0
63+
:geometry (geometry :x "0"
64+
:y "0"
65+
:width "100%"
66+
:height "32px"
67+
:anchor "top center")
68+
:stacking "fg"
69+
:exclusive true
70+
:focusable false
71+
(bar :focused-tags river-focused-tags-1
72+
:urgent-tags river-urgent-tags-1
73+
:view-tags river-view-tags-1))
74+
75+
(defwindow bar-window-2
76+
:monitor 1
77+
:geometry (geometry :x "0"
78+
:y "0"
79+
:width "100%"
80+
:height "32px"
81+
:anchor "top center")
82+
:stacking "fg"
83+
:exclusive true
84+
:focusable false
85+
(bar :focused-tags river-focused-tags-2
86+
:urgent-tags river-urgent-tags-2
87+
:view-tags river-view-tags-2))

0 commit comments

Comments
 (0)