~kris/dots

srice

srice/.config/eww/widgets/dashboard.yuck -rw-r--r-- 16.4 KiB
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
;-------------------------------------------------------
; SYSTEM MONITOR WITH TABS - UPDATED VERSION
;-------------------------------------------------------
(defvar performance_monitor_visible false)
;; Variable active tab
(defvar active_tab "dashboard")

;; ===== POLLING VARIABLES =====

;; Profile polls
(defpoll profile 
  :interval "60s" 
  :initial '{"username": "loading...", "wm": "loading...", "uptime": "...", "image": ""}'
  "~/.config/eww/scripts/profile.sh json")

(defpoll system 
  :interval "2s" 
  :initial '{"cpu_usage": 0, "cpu_temp": 0, "mem_perc": 0, "mem_used": "0G", "mem_total": "0G", "disk_perc": 0, "disk_used": "0G", "disk_total": "0G"}'
  :run-while performance_monitor_visible
  "~/.config/eww/scripts/sys_info.sh")

;; Music polls
(deflisten media_info 
    :initial '{"player": "", "status": "Stopped", "title": "No Media", "artist": "", "cover": ""}'
    "~/.config/eww/scripts/media_listener.sh")

;;Cava polls
(deflisten cava :initial "" `~/.config/eww/scripts/cava.sh`)

;; Weather polls
(defpoll WEATHER_ICON :interval "1800s" "~/.config/eww/scripts/weather-wrapper.sh icon")  
(defpoll WEATHER_DESC :interval "1800s" "~/.config/eww/scripts/weather-wrapper.sh desc")
(defpoll WEATHER_CITY :interval "86400s" "~/.config/eww/scripts/weather-wrapper.sh city")

;; ===== CLOCK POLLING =====
(defpoll times 
  :interval "1s" 
  "date '+{\"h\":\"%H\",\"m\":\"%M\",\"d\":\"%a, %d %b\"}'")

(defpoll my_notes 
  :interval "30s"
  :run-while performance_monitor_visible
  "~/.config/eww/scripts/read_note.sh")

;; Variables info laptop
(defpoll laptop_info :interval "86400s" 
  :initial '{"brand":"Loading...","model":"Loading...","cpu":"...","gpu":"...","ram":"...","disk":"...","logo_path":"..."}'
  "~/.config/eww/scripts/get-laptop-info.sh")

;; Tab Navigation Widget
(defwidget tab_navigation []
  (box :class "tab-navigation"
       :orientation "h"
       :space-evenly true
       :spacing 0
    
    ;; Tab Performance
    (button :class "tab-button ${active_tab == 'performance' ? 'active' : ''}"
            :onclick "eww update active_tab=performance"
      (box :orientation "h"
           :spacing 8
           :space-evenly false
           :halign "center"
           
        (label :class "tab-label" :text "Performance")))
    
    ;; Tab Dashboard
    (button :class "tab-button ${active_tab == 'dashboard' ? 'active' : ''}"
            :onclick "eww update active_tab=dashboard"
      (box :orientation "h"
           :spacing 8
           :space-evenly false
           :halign "center"
        (label :class "tab-label" :text "Dashboard")))

    ;; Tab Information
    (button :class "tab-button ${active_tab == 'information' ? 'active' : ''}"
            :onclick "eww update active_tab=information"
      (box :orientation "h"
           :spacing 8
           :space-evenly false
           :halign "center"
        (label :class "tab-label" :text "Information")))

    ))

;; Metric Bar Widget 
(defwidget metric_bar [icon label value usage_text color_class]
  (box :class "metric-bar-container" 
       :orientation "v" 
       :space-evenly false
       :spacing 8

    ;; Header dengan icon dan label
    (box :class "metric-header"
         :orientation "h"
         :space-evenly false
         :spacing 10
         :valign "center"
      (label :class "metric-icon ${color_class}" 
             :text icon
             :valign "center")
      (box :class "description-metric"
           :orientation "v"
           :space-evenly false
           :spacing 2
           :valign "center"
        (label :class "metric-label" 
               :text label
               :xalign 0)
        (label :class "metric-value-text" 
               :text value
               :xalign 0)
        (label :class "metric-usage-text"
               :text usage_text
               :xalign 0)))))

;;Profile Widget
(defwidget profile_widget []
  (box :class "info-card"
       :orientation "h"  
       :space-evenly false
       :spacing 12
       :valign "center"
    
    ;; Profile Image
    ;; Akses via profile.image
    (box :class "image"
         :style {profile.image != "" ? "background-image: url('${profile.image}');" : "background-image: none;"})
    
    ;; Profile Info
    (box :class "card-content"
         :orientation "v"
         :space-evenly false
         :valign "center"
      
      ;; Username
      ;; Akses via profile.username
      (box :class "info-row"
           :orientation "h" :space-evenly false :spacing 6
        (label :class "info-icon" :text "")
        (label :class "info-text" :limit-width 17 :text {profile.username} :xalign 0))
      
      ;; Window Manager
      ;; Akses via profile.wm
      (box :class "info-row"
           :orientation "h" :space-evenly false :spacing 6
        (label :class "info-icon" :text "")
        (label :class "info-text" :text {profile.wm} :xalign 0))
      
      ;; Uptime
      ;; Akses via profile.uptime
      (box :class "info-row"
           :orientation "h" :space-evenly false :spacing 6
        (label :class "info-icon" :text "")
        (label :class "info-text" :limit-width 17 :text {profile.uptime} :xalign 0)))))

;; Weather Widget
(defwidget weather_widget []
  (box :class "info-card-weather"
       :orientation "h"
       :space-evenly false
       :hexpand true
    
    (box :class "info-row-weather"
         :orientation "h"
         :spacing 0
         :width 133
         :height 106
      (label :class "weather-icon" :text WEATHER_ICON))
    
     ;; Weather info 
    (box :class "card-content"
         :orientation "v"
         :space-evenly false
         :spacing 5
         :valign "center"  
      
      (label :class "info-weather" :limit-width 12 :wrap true :wrap-mode "wordchar" :lines 2 :justify "center" :text WEATHER_CITY :xalign 0.5)
      (label :class "info-text" :limit-width 21 :wrap true :wrap-mode "wordchar" :lines 2 :justify "center" :text WEATHER_DESC :xalign 0.5))
))

(defwidget calendar_box []
    (box :class "calendar-box"
         :orientation "v"
         :space-evenly false

    (calendar :class "cal-widget"
              :vexpand false
              :valign "start")))

;; Clock & Date Widget
(defwidget clock_box []
  (box :class "clock-box"
       :orientation "v"
       :vexpand true
       :valign "fill"

    (box :orientation "v"
         :space-evenly false
         :spacing 8
         :valign "center"
         :vexpand true

      ;; Time Display
      (label :class "clock-time"
             :text {times.h})
      (label :class "clock-separator"
             :text "---")
      (label :class "clock-time"
             :text {times.m})

      ;; Date Display
      (label :class "clock-date"
             :text {times.d}))))

;; Quick Apps Widget
(defwidget apps_box []
  (box :class "apps-box"
       :orientation "v"
       :space-evenly true
       :spacing 5
    
    ;; Row 1
    (box :orientation "h"
         :space-evenly true
         :spacing 5
      
      ;; alacritty
      (button :class "app-button"
              :onclick "alacritty & eww close performance_monitor"
        (label :class "app-icon" :xalign 0.5 :text ""))
      
      ;; pcmanfm
      (button :class "app-button"
              :onclick "pcmanfm & eww close performance_monitor"
        (label :class "app-icon-1" :text "")))
    
    ;; Row 2
    (box :orientation "h"
         :space-evenly true
         :spacing 5
      
      ;; neovim
      (button :class "app-button"
              :onclick "alacritty -e nvim & eww close performance_monitor"
        (label :class "app-icon-2" :text ""))
      
      ;; calibre
      (button :class "app-button"
              :onclick "calibre & eww close performance_monitor"
        (label :class "app-icon-3" :text "")))

    ;; Row 3
    (box :orientation "h"
         :space-evenly true
         :spacing 5
      
      ;; image viewer
      (button :class "app-button"
              :onclick "qimgv & eww close performance_monitor"
        (label :class "app-icon-4" :text ""))
      
      ;; Terminal
      (button :class "app-button"
              :onclick "cheese & eww close performance_monitor"
        (label :class "app-icon-5" :text "")))
    ))

;; WIDGET MEDIA PLAYER
(defwidget media_widget []
  (box :class "media-widget-container"
       :orientation "v"
       :space-evenly false
       :spacing 10
       :vexpand true
  
    ;; Cover Art
    (box :class "media-cover-widget"
         :style {media_info.cover != "" ? "background-image: url('${media_info.cover}'); background-size: contain; background-repeat: no-repeat; background-position: center;" : "background-image: none;"}
         :visible {media_info.cover != ""})
    
    ;; Media Info
    (box :class "media-widget-info"
         :orientation "v"  
         :space-evenly false
         :spacing 5
      
      ;; Label section
      (box :orientation "v"
           :space-evenly false
           :hexpand true
           :halign "center"
        (label :class "media-widget-name"
               :text {media_info.player}
               :visible {media_info.player != ""}
               :xalign 0.5)
        (label :class "media-widget-title"
               :text {media_info.title}
               :limit-width 24
               :xalign 0.5)
        (label :class "media-widget-artist"
               :text {media_info.artist}
               :limit-width 27
               :xalign 0.5))
      
      ;; Controls
      (box :class "media-widget-controls" :halign "center" :spacing 10
        (button :class "media-widget-btn"
                :onclick "playerctl -p ${media_info.player} previous"
          (box :width 40 :height 40 :halign "center" :valign "center"
            (label :text "󰒮" :style "font-size: 37px;")))

        (button :class "media-widget-btn-play"
                :onclick "playerctl -p ${media_info.player} play-pause"
          (box :width 40 :height 40 :halign "center" :valign "center"
            (label :text {media_info.status == "Playing" ? "󰏤" : "󰐊"}
                   :style "font-size: 43px;")))

        (button :class "media-widget-btn"
                :onclick "playerctl -p ${media_info.player} next"
          (box :width 40 :height 40 :halign "center" :valign "center"
            (label :text "󰒭" :style "font-size: 37px;"))))
      )))

;;CAVA Widget
(defwidget cava []
  (box :class "cava-container"
       :orientation "v"
    (label :text "${cava}" 
           :class "cava")))

;; NOTE BOX
(defwidget note_box []
  (box :class "note-container"
       :orientation "v"
       :halign "center"
       :valign "center"
    (button :class "edit-btn"
            :onclick "xdg-open ~/.config/eww/my-notes.txt &"
      (box :orientation "v"
           :space-evenly false
           :valign "center"
          (label :text my_notes
                 :class "note-text"
                 :xalign 0.5
                 :yalign 0.5
                 :limit-width 21
                 :wrap true 
                 :wrap-mode "wordchar" 
                 :lines 2 
                 :justify "center")))))

;; Performance Content Widget
(defwidget performance_content []
  (box :class "tab-content" 
       :orientation "h" 
       :spacing 10
       :space-evenly true
    
    ;; CPU
    (metric_bar 
        :icon ""
        :label "CPU"
        :value "${system.cpu_temp}°C"
        :usage_text "${system.cpu_usage}% Usage"
        :color_class "cpu-color")
    
    ;; Memory
    (metric_bar 
        :icon ""
        :label "RAM"
        :value "${system.mem_used} / ${system.mem_total}"
        :usage_text "${system.mem_perc}% Used"
        :color_class "mem-color")
    
    ;; Disk
    (metric_bar 
        :icon ""
        :label "Disk"
        :value "${system.disk_used} / ${system.disk_total}"
        :usage_text "${system.disk_perc}% Used"
        :color_class "disk-color")))

;; Widget box utama
(defwidget laptop-info-widget []
  (box :class "laptop-container"
       :orientation "h"
       :space-evenly false
       :spacing 10
    
    ;; Logo laptop dari cache
  (box :class "logo-section"
         :halign "center"
      (image :path {laptop_info.logo_path}
             :image-width 67
             :image-height 67
             :visible {laptop_info.logo_path != ""}))
    
    ;; Info spesifikasi
    (box :class "specs-section"
         :orientation "v"
         :space-evenly false
         :spacing 0
      
      ;; Brand & Model
      (box :class "brand-row"
           :space-evenly false
           :spacing 10
           :orientation "h"
        (label :class "spec-brand" :text "${laptop_info.model}"))
      
      ;; CPU
      (box :class "spec-row"
           :space-evenly false
           :spacing 10
        (box :orientation "h" :space-evenly false :spacing 10
          (label :class "spec-label" :width 93 :text "CPU" :xalign 0)
          (label :class "spec-value" :text "${laptop_info.cpu}" :halign "start")))
      
      ;; GPU
      (box :class "spec-row"
           :space-evenly false
           :spacing 10
        (box :orientation "h" 
             :space-evenly false
             :spacing 10
             :width 400
          (label :class "spec-label" :text "GPU" :width 93 :xalign 0)
          (label :class "spec-value" 
                 :text "${laptop_info.gpu}" 
                 :wrap true 
                 :limit-width 47
                 :lines 2
                 :justify "left" 
                 :halign "start")))
      
      ;; RAM
      (box :class "spec-row"
           :space-evenly false
           :spacing 0
       (box :orientation "h" :space-evenly false :spacing 10
          (label :class "spec-label" :text "Memory" :width 93 :xalign 0)
          (label :class "spec-value" :text "${laptop_info.ram}" :halign "start")))
      
      ;; Disk
      (box :class "spec-row"
           :space-evenly false
           :spacing 0
        (box :orientation "h" :space-evenly false :spacing 10
          (label :class "spec-label" :text "Storage" :width 93 :xalign 0)
          (label :class "spec-value" :text "${laptop_info.disk}" :halign "start"))))))
          
;; Dashboard Content Widget 
(defwidget dashboard_content []
  (box :class "tab-content other-content"
       :orientation "h"   
       :space-evenly false
       :spacing 10
    
    ;;KOLOM KIRI
    (box :orientation "v"
         :spacing 10
         :space-evenly false
      
      ;; Row 1: Profile and Weather
      (box :class "column"
           :orientation "h"
           :spacing 10
           :space-evenly false

        (profile_widget)
        (weather_widget))
      
      ;; Row 2: Calendar, Clock, Apps
      (box :class "column"
           :orientation "h"
           :spacing 10
           :hexpand true
           :space-evenly false

        (clock_box)
        (calendar_box)
        (apps_box)))
    
    ;; KOLOM KANAN
    (box :class "right-column"
         :orientation "v"
         :spacing 10
         :space-evenly false
         :vexpand true
      (media_widget)
      (cava)
      (note_box))    
  ))

;; Main Widget
(defwidget main_widget []
  (box :class "main-container"
       :orientation "v"
       :space-evenly false
    
    ;; Tab Navigation (Tombol Atas)
    (tab_navigation)
    
    ;; Kita mapping logic: dashboard=0, performance=1, information=2
    (box :class "content-area"
      (stack :selected {active_tab == "dashboard" ? 0 : active_tab == "performance" ? 1 : 2}
             :transition "slideleft" ;; Animasi gratis! (bisa crossfade, slideright, dll)
        
        ;; Index 0: Dashboard Content
        (dashboard_content)
        
        ;; Index 1: Performance Content
        (performance_content)

        ;; Index 2: Information Content
        (laptop-info-widget)
      )
    )
  )
)

;; ----------------------------------------
;; CLICKABLE OVERLAY TO CLOSE DASHBOARD
;; ----------------------------------------
(defwindow dashboard_overlay
  :monitor 0
  :geometry (geometry :x "0%"
                      :y "0%"
                      :width "100%"
                      :height "100%"
                      :anchor "center center")
  :stacking "bg"
  :windowtype "dock"
  :wm-ignore true
  :focusable false
  (eventbox :onclick "eww close performance_monitor dashboard_overlay && eww update performance_monitor_visible=false"
    (box :class "dashboard-overlay")))

;; ----------------------------------------
;; JENDELA UTAMA
;; ----------------------------------------
(defwindow performance_monitor
  :monitor 0
  :geometry (geometry :x "0%"
                      :y "45px"
                      :width "930px"
                      :height "510px"
                      :anchor "top center")
  :stacking "overlay"
  :exclusive true
  :windowtype "dialog"
  :wm-ignore true
  :focusable false
  :resizable false
  (main_widget))