blob: 27eb4c4353f6a5125b2cbf67c3afef1b07255068 [file] [log] [blame]
Samuel Shuert3f828662024-02-10 20:45:50 -05001;; Variables
2(defpoll clock_time :interval "5m" "date +\%I")
3(defpoll clock_minute :interval "5s" "date +\%M")
4(defpoll clock_date :interval "10h" "date '+%d/%m'")
5(defpoll volume_percent :interval "3s" "amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'")
6(defpoll mic_percent :interval "3s" "amixer -D pulse sget Capture | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'")
7(defpoll brightness_percent :interval "5s" "brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}' | tr -d '%'")
8(defpoll battery :interval "15s" "./scripts/battery --bat")
9(defpoll battery_status :interval "1m" "./scripts/battery --bat-st")
10(defpoll memory :interval "15s" "scripts/memory")
11(defpoll memory_used_mb :interval "2m" "scripts/mem-ad used")
12(defpoll memory_total_mb :interval "2m" "scripts/mem-ad total")
13(defpoll memory_free_mb :interval "2m" "scripts/mem-ad free")
14(defvar vol_reveal false)
15(defvar br_reveal false)
16(defvar music_reveal false)
17(defvar wifi_rev false)
18(defvar time_rev false)
19(deflisten workspace "scripts/workspace")
20
21(defvar eww "$HOME/.local/bin/eww/eww -c $HOME/.config/eww/bar")
22
23
24(defpoll COL_WLAN :interval "1m" "~/.config/eww/bar/scripts/wifi --COL")
25(defpoll ESSID_WLAN :interval "1m" "~/.config/eww/bar/scripts/wifi --ESSID")
26(defpoll WLAN_ICON :interval "1m" "~/.config/eww/bar/scripts/wifi --ICON")
27
28
29(defpoll song :interval "2s" "~/.config/eww/bar/scripts/music_info --song")
30(defpoll song_artist :interval "2s" "~/.config/eww/bar/scripts/music_info --artist")
31(defpoll current_status :interval "1s" "~/.config/eww/bar/scripts/music_info --time")
32(defpoll song_status :interval "2s" "~/.config/eww/bar/scripts/music_info --status")
33(defpoll cover_art :interval "2s" "~/.config/eww/bar/scripts/music_info --cover")
34
35(defpoll calendar_day :interval "20h" "date '+%d'")
36(defpoll calendar_year :interval "20h" "date '+%Y'")
37
38;; widgets
39
40(defwidget wifi []
41 (eventbox :onhover "${eww} update wifi_rev=true"
42 :onhoverlost "${eww} update wifi_rev=false"
43 (box :vexpand "false" :hexpand "false" :space-evenly "false"
44 (button :class "module-wif" :onclick "networkmanager_dmenu" :wrap "false" :limit-width 12 :style "color: ${COL_WLAN};" WLAN_ICON)
45 (revealer :transition "slideright"
46 :reveal wifi_rev
47 :duration "350ms"
48 (label :class "module_essid"
49 :text ESSID_WLAN
50 :orientation "h"
51 )))))
52
53
54(defwidget workspaces []
55 (literal :content workspace))
56
57
58(defwidget bat []
59 (box :class "bat_module" :vexpand "false" :hexpand "false"
60 (circular-progress :value battery
61 :class "batbar"
62 :thickness 4
63 (button
64 :class "iconbat"
65 :limit-width 2
66 :tooltip "battery on ${battery}%"
67 :show_truncated false
68 :onclick "$HOME/.config/eww/bar/scripts/pop system"
69 :wrap false
70 ""))))
71
72
73(defwidget mem []
74 (box :class "mem_module" :vexpand "false" :hexpand "false"
75 (circular-progress :value memory
76 :class "membar"
77 :thickness 4
78 (button
79 :class "iconmem"
80 :limit-width 2
81 :tooltip "using ${memory}% ram"
82 :onclick "$HOME/.config/eww/bar/scripts/pop system"
83 :show_truncated false
84 :wrap false
85 ""))))
86
87
88
89(defwidget sep []
90 (box :class "module-2" :vexpand "false" :hexpand "false"
91 (label :class "separ" :text "|")))
92
93(defwidget clock_module []
94 (eventbox :onhover "${eww} update time_rev=true"
95 :onhoverlost "${eww} update time_rev=false"
96 (box :class "module" :space-evenly "false" :orientation "h" :spacing "3"
97 (label :text clock_time :class "clock_time_class" )
98 (label :text "" :class "clock_time_sep" )
99 (label :text clock_minute :class "clock_minute_class")
100 (revealer :transition "slideleft"
101 :reveal time_rev
102 :duration "350ms"
103 (button :class "clock_date_class"
104 :onclick "$HOME/.config/eww/bar/scripts/pop calendar" clock_date
105 )
106 ))))
107
108(defwidget volume []
109 (eventbox :onhover "${eww} update vol_reveal=true"
110 :onhoverlost "${eww} update vol_reveal=false"
111 (box :class "module-2" :space-evenly "false" :orientation "h" :spacing "3"
112 (button :onclick "scripts/pop audio" :class "volume_icon" "")
113 (revealer :transition "slideleft"
114 :reveal vol_reveal
115 :duration "350ms"
116 (scale :class "volbar"
117 :value volume_percent
118 :orientation "h"
119 :tooltip "${volume_percent}%"
120 :max 100
121 :min 0
122 :onchange "amixer -D pulse sset Master {}%" )))))
123
124(defwidget bright []
125 (eventbox :onhover "${eww} update br_reveal=true" :onhoverlost "${eww} update br_reveal=false"
126 (box :class "module-2" :space-evenly "false" :orientation "h" :spacing "3"
127 (label :text "" :class "bright_icon" :tooltip "brightness")
128 (revealer :transition "slideleft"
129 :reveal br_reveal
130 :duration "350ms"
131 (scale :class "brightbar"
132 :value brightness_percent
133 :orientation "h"
134 :tooltip "${brightness_percent}%"
135 :max 100
136 :min 0
137 :onchange "brightnessctl set {}%" )))))
138
139
140
141 ;; Music
142(defwidget music []
143 (eventbox :onhover "${eww} update music_reveal=true"
144 :onhoverlost "${eww} update music_reveal=false"
145 (box :class "module-2" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
146 (box :class "song_cover_art" :vexpand "false" :hexpand "false" :style "background-image: url('${cover_art}');")
147 (button :class "song" :wrap "true" :onclick "~/.config/eww/bar/scripts/pop music" song)
148 (revealer :transition "slideright"
149 :reveal music_reveal
150 :duration "350ms"
151 (box :vexpand "false" :hexpand "false" :oreintation "h"
152 (button :class "song_btn_prev" :onclick "~/.config/eww/bar/scripts/music_info --prev" "")
153 (button :class "song_btn_play" :onclick "~/.config/eww/bar/scripts/music_info --toggle" song_status)
154 (button :class "song_btn_next" :onclick "~/.config/eww/bar/scripts/music_info --next" ""))))))
155
156
157
158(defwidget left []
159 (box :orientation "h"
160 :space-evenly false
161 :halign "end"
162 :class "left_modules"
163(bright)
164(volume)
165(wifi)
166(sep)
167(bat)
168(mem)
169(sep)
170(clock_module)))
171
172
173(defwidget right []
174 (box :orientation "h"
175 :space-evenly false
176 :halign "start"
177 :class "right_modules"
178(workspaces)))
179
180
181(defwidget center []
182 (box :orientation "h"
183 :space-evenly false
184 :halign "center"
185 :class "center_modules"
186(music)))
187
188(defwidget bar_1 []
189 (box :class "bar_class"
190 :orientation "h"
191 (right)
192 (center)
193 (left)
194 ))
195
196(defwindow bar
197 :geometry (geometry :x "0%"
198 :y "9px"
199 :width "98%"
200 :height "30px"
201 :anchor "top center")
202 :stacking "fg"
203 :windowtype "dock"
204 (bar_1))
205
206(defwidget system []
207 (box :class "sys_win" :orientation "v" :space-evenly "false" :hexpand "false" :vexpand "false" :spacing 0
208 (box :class "sys_bat_box" :orientation "h" :space-evenly "false"
209 (circular-progress :value battery
210 :class "sys_bat"
211 :thickness 9
212 (label :text ""
213 :class "sys_icon_bat"
214 :limit-width 2
215 :show_truncated false
216 :wrap false))
217 (box :orientation "v" :space-evenly "false" :spacing 0 :hexpand "false" :vexpand "false"
218 (label :text "battery"
219 :halign "start"
220 :class "sys_text_bat"
221 :limit-width 9
222 :show_truncated false
223 :wrap false)
224 (label :text "${battery}%"
225 :halign "start"
226 :class "sys_text_bat_sub"
227 :limit-width 22
228 :show_truncated false
229 :wrap false)
230 (label :text "${battery_status}"
231 :halign "start"
232 :class "sys_text_bat_sub"
233 :limit-width 22
234 :show_truncated false
235 :wrap false)))
236 (label :text "" :class "sys_sep" :halign "center")
237 (box :class "sys_mem_box" :orientation "h" :space-evenly "false" :halign "start"
238 (circular-progress :value memory
239 :class "sys_mem"
240 :thickness 9
241 (label :text ""
242 :class "sys_icon_mem"
243 :limit-width 2
244 :show_truncated false
245 :wrap false
246 :angle 0.0))
247 (box :orientation "v" :space-evenly "false" :spacing 0 :hexpand "false" :vexpand "false"
248 (label :text "memory"
249 :halign "start"
250 :class "sys_text_mem"
251 :limit-width 9
252 :show_truncated false
253 :wrap false)
254 (label :text "${memory_used_mb} | ${memory_total_mb}mb "
255 :halign "start"
256 :class "sys_text_mem_sub"
257 :limit-width 22
258 :show_truncated false
259 :wrap false)
260 (label :text "${memory_free_mb}mb free"
261 :halign "start"
262 :class "sys_text_mem_sub"
263 :limit-width 22
264 :show_truncated false
265 :wrap false)))))
266
267(defwidget cal []
268 (box :class "cal" :orientation "v"
269 (box :class "cal-in"
270 (calendar :class "cal"
271 :day calendar_day
272 :year calendar_year))))
273
274(defwindow calendar
275 :geometry (geometry :x "-20px"
276 :y "7%"
277 :anchor "top right"
278 :width "270px"
279 :height "60px")
280(cal))
281
282
283
284(defwidget audio []
285 (box :class "audio-box" :orientation "v" :space-evenly "false" :vexpand "false" :hexpand "false"
286 (box :halign "v" :space-evenly "false" :hexpand "false" :vexpand "false"
287 (box :class "speaker_icon" :orientation "v")
288 (box :orientation "v" :halign "center" :vexpand "false" :hexpand "false"
289 (label :class "speaker_text" :text "speaker" :valign "center" :halign "left" )
290 (box :class "speaker_bar" :halign "center" :vexpand "false" :hexpand "false"
291 (scale :value volume_percent
292 :space-evenly "false"
293 :orientation "h"
294 :onchange "amixer -D pulse sset Master {}%"
295 :tooltip "volume on ${volume_percent}%"
296 :max 100
297 :min 0))))
298 (label :text "" :class "audio_sep" :halign "center")
299 (box :halign "v" :space-evenly "false" :hexpand "false" :vexpand "false"
300 (box :class "mic_icon" :orientation "v")
301 (box :orientation "v" :halign "center" :vexpand "false" :hexpand "false"
302 (label :class "mic_text" :text "mic" :valign "center" :halign "left" )
303 (box :class "mic_bar" :halign "center" :vexpand "false" :hexpand "false"
304 (scale :value mic_percent
305 :space-evenly "false"
306 :orientation "h"
307 :tooltip "mic on ${mic_percent}%"
308 :onchange "amixer -D pulse sset Capture {}%"
309 :max 100
310 :min 0))))))
311
312(defwindow audio_ctl
313 :geometry (geometry :x "-20px"
314 :y "7%"
315 :anchor "top right"
316 :width "280px"
317 :height "60px")
318(audio))
319
320
321(defwindow system
322 :geometry (geometry :x "-20px"
323 :y "7%"
324 :anchor "top right"
325 :width "290px"
326 :height "120px")
327(system))
328
329
330
331;; Music
332(defwidget music_pop []
333 (box :class "music_pop" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
334 (box :class "music_cover_art" :vexpand "false" :hexpand "false" :style "background-image: url('${cover_art}');")
335 (box :orientation "v" :spacing 20 :space-evenly "false" :vexpand "false" :hexpand "false"
336 (label :halign "center" :class "music" :wrap "true" :limit-width 13 :text song)
337 (label :halign "center" :class "music_artist" :wrap "true" :limit-width 15 :text song_artist)
338 (box :orientation "h" :spacing 15 :halign "center" :space-evenly "false" :vexpand "false" :hexpand "false"
339 (button :class "music_btn_prev" :onclick "~/.config/eww/bar/scripts/music_info --prev" "")
340 (button :class "music_btn_play" :onclick "~/.config/eww/bar/scripts/music_info --toggle" song_status)
341 (button :class "music_btn_next" :onclick "~/.config/eww/bar/scripts/music_info --next" ""))
342 (box :class "music_bar" :halign "center" :vexpand "false" :hexpand "false" :space-evenly "false"
343 (scale :onscroll "mpc -q seek {}" :min 0 :active "true" :max 100 :value current_status)))))
344
345
346;; music
347 (defwindow music_win :stacking "fg" :focusable "false" :screen 1
348 :geometry (geometry :x "0" :y "7%" :width 428 :height 104 :anchor "top center")
349 (music_pop))
350