blob: a7695acd0ec74f6f27506bf507b17481038b1eae [file] [log] [blame]
Skyler Greya0da6b22024-02-11 22:53:41 +00001(defwidget bar []
2 (centerbox :orientation "h"
3 :class "bar"
4 (workspaces)
5 (music)
6 (sidestuff)))
7
8(defwidget sidestuff []
9 (box :class "sidestuff" :orientation "h" :space-evenly false :halign "end"
10 (metric :label "🔊"
11 :value volume
Skyler Grey4e230892024-02-13 22:58:46 +000012 :onchange "nix run nixpkgs#pamixer -- --set-volume {}")
13 (radio)
14 (sysinfo)
15 time))
16
17(defwidget radio []
18 (box :class "radio" :orientation "h" :space-evenly false :halign "end"
19 (button :class bluetooth
20 :onclick { bluetooth == "inactive" ? "bluetoothctl power on" : "bluetoothctl power off"}
21 "īŠ“")
22 (button :class wifi
23 :onclick { wifi == "disabled" ? "nmcli radio wifi on" : "nmcli radio wifi off"}
24 "🛜")
25 )
26)
27
28(defwidget sysinfo []
29 (box :class "sysinfo"
30 ; (metric :label { battery_status == "Normal" ? "🔋" : "đŸĒĢ" }
31 ; :value battery_cap
32 ; :onchange "")
33 (metric :label "🐏"
Skyler Greya0da6b22024-02-11 22:53:41 +000034 :value {EWW_RAM.used_mem_perc}
35 :onchange "")
36 (metric :label "💾"
37 :value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)}
38 :onchange "")
Skyler Grey4e230892024-02-13 22:58:46 +000039 (metric :label "🕓"
40 :value cpu_usage_percent
41 :onchange "")
42 )
43)
Skyler Greya0da6b22024-02-11 22:53:41 +000044
45(defwidget workspaces []
46 (box :class "workspaces"
47 :orientation "h"
48 :space-evenly true
49 :halign "start"
50 :spacing 10
Skyler Grey4e230892024-02-13 22:58:46 +000051 (button :onclick "hyprctl dispatch workspace 1" 1)
52 (button :onclick "hyprctl dispatch workspace 2" 2)
53 (button :onclick "hyprctl dispatch workspace 3" 3)
54 (button :onclick "hyprctl dispatch workspace 4" 4)
55 (button :onclick "hyprctl dispatch workspace 5" 5)
56 (button :onclick "hyprctl dispatch workspace 6" 6)
57 (button :onclick "hyprctl dispatch workspace 7" 7)
58 (button :onclick "hyprctl dispatch workspace 8" 8)
59 (button :onclick "hyprctl dispatch workspace 9" 9)
60 (button :onclick "hyprctl dispatch workspace 0" 0)
61 ))
Skyler Greya0da6b22024-02-11 22:53:41 +000062
63(defwidget music []
64 (box :class "music"
65 :orientation "h"
66 :space-evenly false
67 :halign "center"
Skyler Grey4e230892024-02-13 22:58:46 +000068 :onclick ""
Skyler Greya0da6b22024-02-11 22:53:41 +000069 {music != "" ? "đŸŽĩ${music}" : ""}))
70
71
72(defwidget metric [label value onchange]
73 (box :orientation "h"
74 :class "metric"
75 :space-evenly false
76 (box :class "label" label)
77 (scale :min 0
78 :max 101
79 :active {onchange != ""}
80 :value value
81 :onchange onchange)))
82
Skyler Greya0da6b22024-02-11 22:53:41 +000083(deflisten music :initial ""
Skyler Grey4e230892024-02-13 22:58:46 +000084"nix run nixpkgs#playerctl -- --follow metadata --format '{{ title }}' || true")
85
86(defpoll bluetooth :interval "1s"
87"rfkill -o TYPE,SOFT list -n | grep bluetooth | sed -E 's/bluetooth\s+//g'")
88
89(defpoll wifi :interval "1s"
90"rfkill -o TYPE,SOFT list -n | grep wlan | sed -E 's/wlan\s+//g'")
Skyler Greya0da6b22024-02-11 22:53:41 +000091
92(defpoll volume :interval "1s"
Skyler Grey4e230892024-02-13 22:58:46 +000093"nix run nixpkgs#pamixer -- --get-volume")
Skyler Greya0da6b22024-02-11 22:53:41 +000094
Skyler Grey4e230892024-02-13 22:58:46 +000095(defpoll battery_cap :interval "5m"
96"cat /sys/class/power_supply/BAT*/capacity"
97)
Skyler Greya0da6b22024-02-11 22:53:41 +000098
Skyler Grey4e230892024-02-13 22:58:46 +000099(defpoll battery_status :interval "1s"
100"cat /sys/class/power_supply/BAT*/status"
101)
102
103(defpoll cpu_usage_percent :interval "5s"
104"bash scripts/cpu_usage"
105)
106
107(defpoll time :interval "1s"
108"date '+%H:%M:%S %b %d, %Y'")
109
110(defwindow bar-primary
Skyler Greya0da6b22024-02-11 22:53:41 +0000111 :monitor 0
112 :windowtype "dock"
113 :geometry (geometry :x "0%"
114 :y "0%"
115 :width "100%"
116 :height "10px"
117 :anchor "top center")
118 :exclusive true
119 (bar))