summaryrefslogtreecommitdiff
path: root/.config/eww/bar.yuck
blob: c0c0b87af9bdf363a63424fea56c14b82996b2fc (plain)
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
(deflisten tags_json :initial `[]` `river-bedload -minified -watch tags`)
; (deflisten wintitle :initial `[{"title":""}]` `river-bedload -minified -watch title`)
(defpoll song :initial "" :interval "5s" `rmpc song`)
(deflisten cava :initial "" `cava -p ~/.config/eww/cava.ini | python3 ~/.config/eww/cava.py`)

(deflisten volume :initial "0" `monitor-volume`)
(defpoll ssid :initial "" :interval "10s" `iwctl station wlan0 get-networks | awk -F'  ' '/>/{print $3}'`)
(deflisten brightness :initial "0" `brightctl -l`)
(defpoll bartime :initial "" :interval "1s" `date '+%b %-d %H:%M:%S'`)

(defwindow bar [output]
           :monitor 0
           :geometry (geometry :x "0%"
                               :y "8px"
                               :width "1904px"
                               :height "32px"
                               :anchor "top center")
           :stacking "fg"
           :exclusive true
           :focusable false
  (bar :output output))

(defwidget bar [output]
  (centerbox :orientation "h"
             :class "bar"
    (tags :output output)
    (music)
    (status)))

(defwidget tags [output]
  (box :orientation "h"
       :halign "start"
       :class "tags"
    (for tag in "[1, 2, 3, 4, 5, 6, 7, 8, 9]"
      (button :onclick `riverctl set-focused-tags $(dc -e"2 ${tag} 1- ^p")`
              :class {jq(tags_json, `.[] | select(.output == "${output}" and .id == ${tag}) | {focused, occupied} | to_entries | map(select(.value) | .key) | join(" ") | {"class": .}`).class}))))

(defwidget music []
  (box :orientation "h"
       :spacing 4
       :space-evenly false
       :class "music"
    (label :text "${song.metadata.artist} - ${song.metadata.title}"
           :class "song"
           :show-truncated true
           :limit-width 55)
    (label :text {cava} :class "cava")))


(defwidget title []
  (label :text {wintitle[0].title}
         :class "title"
         :show-truncated true
         :visible {wintitle[0].title != ""}
         :limit-width 55))

;(defvar showvol false)

(defwidget status []
  (box :orientation "h"
       :halign "end"
       :class "status"
       :spacing 8
       :space-evenly false
    ;(revealer-on-hover :var showvol
                       ;:varname "showvol"
                       ;:icon "a"
                       ;:transition "slideleft"
                       ;:class "volume"
      ;(scale :orientation "h"
             ;:min 0
             ;:max 1
             ;:value {volume}
             ;:onchange `wpctl set-volume @DEFAULT_SINK@ {}`)
    (label :text "${matches(volume, "MUTED") ? " " : volume == 0 ? "" : volume < 50 ? "" : " "} ${volume}%"
           :class "volume")
    (label :text "${ssid == "" ? "󰖪" : "󰖩"} ${ssid}"
           :class "network")
    (label :text " ${brightness}%"
           :class "brightness")
    (label :text "${`{"Discharging": ["󰁺","󰁻","󰁼","󰁽","󰁾","󰁿","󰂀","󰂁","󰂂","󰁹"], "Charging": ["󰢜","󰂆","󰂇","󰂈","󰢝","󰂉","󰢞","󰂊","󰂋","󰂅"]}`?.[EWW_BATTERY.BAT0.status]?.[round((EWW_BATTERY.BAT0.capacity - 1) / 10, 0)] ?: "󰂄"} ${EWW_BATTERY.BAT0.capacity}%"
           :class "battery")
    (label :text " ${bartime}"
           :class "clock")
    ;(label :text "󰍜"
           ;:class "menu")))
    (label :text "󰐥"
           :class "power")))