-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheww.yuck
executable file
·253 lines (235 loc) · 6.59 KB
/
eww.yuck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
;; Widget variables
(defpoll battery :interval "5s" "scripts/battery")
(deflisten music-status :initial "" "scripts/music-status")
(defpoll ram-usage :interval "1s" "scripts/ram-usage")
(defpoll time :interval "1s" "date '+%a %b %d, %Y %H:%M'")
(deflisten volume-status "scripts/volume-status")
(deflisten window :initial "" "scripts/window-name")
(deflisten workspaces :initial "" "scripts/workspaces")
(deflisten notifications :inital "" "scripts/notifications")
;; Toggles
(defvar cpu-expanded false)
(defwidget workspace-widget [spaces]
(box
:space-evenly false
:class "workspaces-wrapper"
(for workspace in spaces
(button
:onclick "sway workspace ${workspace.name}"
(box
:space-evenly false
:class "workspace-wrapper ${workspace.visible ? 'visible' : ''} ${workspace.focused ? 'focused' : ''}"
(label :text {workspace.name})
(box
:class "workspace__icon-wrapper"
(for client in {workspace.clients}
(image
:image-width 24
:path {client.icon}
:visible {client.icon != ""}))))))))
(defwidget metric [label value onchange]
(box :orientation "v"
:class "metric"
:space-evenly false
:halign "center"
(label
:limit-width 40
:text label)
(scale :min 0
:max 101
:active {onchange != ""}
:value {value ?: 0}
:onchange onchange)))
(defwidget icon-pill [icon name icon-class on-icon-click]
(box :class "${name}__wrapper icon-pill"
:orientation "h"
:space-evenly false
:halign "center"
(button
:onclick on-icon-click
(label
:class "icon-pill__icon ${name}__icon ${icon-class}"
:text icon))
(children)))
(defwidget system-bar [value]
(scale
:min 0
:max 101
:class {value < 25 ? "low" :
value < 50 ? "medium" :
value < 90 ? "high" : "max"}
:value {value}
:flipped true
:orientation "v"))
(defwidget music []
(box
:visible {music-status != ""}
(icon-pill
:name "music"
:icon {music-status.status == "playing" ? " " : " "}
:icon-class {music-status.status}
:on-icon-click "playerctl play-pause"
(metric
:label "${music-status.artist} - ${music-status.title}"
:value {round(music-status.position / music-status.length * 100, 0)}
:onchange ""))))
(defwidget volume []
(box
:orientation "h"
:visible {volume-status != ""}
(icon-pill
:name "volume-sink"
:icon "${volume-status.sink.muted ? '' : ''}"
:icon-class "volume-sink ${volume-status.sink.muted ? 'muted' :''}"
:on-icon-click "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
(box
:orientation "h"
:space-evenly false
:class "volume-wrapper"
(scale :min 0
:max 101
:value {volume-status.sink.volume}
:orientation "v"
:onchange "./scripts/set-volume @DEFAULT_AUDIO_SINK@ {}")))
(icon-pill
:name "volume-source"
:icon "${volume-status.source.muted ? '' : ''}"
:icon-class "volume-source ${volume-status.source.muted ? 'muted' :''}"
:on-icon-click "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
(box
:orientation "h"
:space-evenly false
:class "volume-wrapper"
(scale :min 0
:max 101
:value {volume-status.source.volume}
:orientation "v"
:onchange "./scripts/set-volume @DEFAULT_AUDIO_SOURCE@ {}")))))
(defwidget cpu []
(eventbox
:onclick "${EWW_CMD} update cpu-expanded=${!cpu-expanded}"
(icon-pill
:name "cpu"
:icon ""
:icon-class "cpu"
:on-icon-click ""
(box
:orientation "h"
:space-evenly false
:class "cpu-wrapper"
(revealer
:transition "slideleft"
:reveal {! cpu-expanded}
(system-bar
:value {EWW_CPU.avg}))
(revealer
:transition "slideright"
:reveal cpu-expanded
:duration "250ms"
(box
:orientation "h"
:space-evenly false
(for cpu in {EWW_CPU.cores}
(system-bar
:value {cpu.usage}))))))))
(defwidget ram []
(icon-pill
:name "ram"
:icon ""
:icon-class "ram"
:on-icon-click ""
(box
:orientation "h"
:space-evenly false
:class "ram-wrapper"
(for ram in ram-usage
(system-bar
:value ram)))))
(defwidget clock []
(icon-pill
:name "clock"
:icon ""
:icon-class "clock"
:on-icon-click ""
(label
:text time)))
(defwidget swaync []
(box :class "notifications-wrapper"
(button
:visible "which swaync-client"
:onclick "sleep 0.1; swaync-client -t -sw"
:onrightclick "sleep 0.1; swaync-client -d -sw"
(box
(label :markup {notifications})))))
(defwidget left [index]
(workspace-widget
:spaces {workspaces[index]}))
(defwidget center []
(box
:space-evenly false
:halign "fill"
:class "window-wrapper"
:tooltip {window.name}
(image
:image-width 24
:path {window.icon ?: "./assets/sway.png"})
(label :text {window.name}
:limit-width 50)))
(defwidget right []
(box
:space-evenly false
:halign "end"
(music)
(cpu)
(ram)
(volume)
(clock)
(systray :pack-direction "ltr"
:icon-size 16)
(swaync)))
;; TODO Make this much less crap...
(defwindow bar-eDP-1
:monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:anchor "top center")
:stacking "fg"
:exclusive true
(centerbox
:class "bar"
:orientation "h"
(left
:index 0)
(center)
(right)))
(defwindow bar-DP-2
:monitor 1
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:anchor "top center")
:stacking "fg"
:exclusive true
(centerbox
:class "bar"
:orientation "h"
(left
:index 1)
(center)
(right)))
(defwindow bar-DP-3
:monitor 2
:geometry (geometry :x "0%"
:y "0%"
:width "100%"
:anchor "top center")
:stacking "fg"
:exclusive true
(centerbox
:class "bar"
:orientation "h"
(left
:index 2)
(center)
(right)))