(defpoll bar-audio-icon :interval "1s" :initial "" `~/.config/eww/widgets/bar/scripts/audio.sh`)
(defpoll bar-audio-volume :interval "1s" :initial "" `pactl --format="json" get-sink-volume $(pactl get-default-sink) | jq '.volume | map(.value) | length as $amount | add / $amount'`)

(defwidget bar-audio []
  (eventbox
    :onclick "hyprctl dispatch exec pavucontrol"
    :onrightclick "hyprctl dispatch exec rofi -show pactl"
    (box
      :hexpand false
      :halign "end"
      :space-evenly false
      :spacing 20
      :class "widget default-padding"

      {bar-audio-icon}
      (progress
        :valign "center"
        :value {(bar-audio-volume / 65536) * 100}
      )
    )
  )
)
