61 lines
1.5 KiB
Plaintext
61 lines
1.5 KiB
Plaintext
(defwidget bar []
|
|
(centerbox :orientation "h"
|
|
(sidestuff)
|
|
(box)
|
|
(music)))
|
|
|
|
(defwindow bar
|
|
:monitor 2
|
|
:stacking "fg"
|
|
:exclusive true
|
|
:geometry
|
|
(geometry
|
|
:x "0%"
|
|
:y "0%"
|
|
:width "100%"
|
|
:height "31px"
|
|
:anchor "bottom center")
|
|
(bar))
|
|
|
|
(defwidget sidestuff []
|
|
(box :class "sidestuff" :orientation "h" :space-evenly false :halign "start" :spacing 20
|
|
time
|
|
; TODO: idle inhibitor?
|
|
; TODO: get these to align properly?
|
|
(box :class "mic" (box :class {micMuted == "false" ? "muted" : "live"} {micMuted == "false" ? " " : " "}))
|
|
{" " + volume}
|
|
{" " + cpu}
|
|
{" " + ram}
|
|
; TODO: brightness
|
|
; TODO: battery
|
|
))
|
|
|
|
(defwidget music []
|
|
(box :class "music"
|
|
:orientation "h"
|
|
:halign "end"
|
|
:space-evenly false
|
|
{music != "" ? "${music}" : ""}))
|
|
|
|
(deflisten music :initial ""
|
|
"playerctl --follow metadata --format '{{ title }} by {{ artist }}' || true")
|
|
|
|
; convert these to `deflisten`s as well because polling is very silly
|
|
(defpoll volume :interval "1s"
|
|
"pamixer --get-volume")
|
|
|
|
(defpoll micVolume :interval "10s"
|
|
"pamixer --default-source --get-volume")
|
|
|
|
(defpoll micMuted :interval "1s"
|
|
"pamixer --default-source --get-mute")
|
|
|
|
(defpoll cpu :interval "1s"
|
|
"mpstat -o JSON | jq -r '(100 - .sysstat.hosts[0].statistics[0][\"cpu-load\"][0].idle | round | tostring)+\"%\"'")
|
|
|
|
(defpoll ram :interval "1s"
|
|
"free | grep Mem | awk '{printf \"%.0f%\", $3/$2 * 100.0}'")
|
|
|
|
(defpoll time :interval "1s"
|
|
"date '+%a %b %d %H:%M:%S'")
|