(defvar reveal_volume false)
(defwidget volume []
  (revealer-on-hover
    :revealvar reveal_volume
    :revealvar-name "reveal_volume"
    (button :onclick 'pavucontrol-qt --tab 3'
            :class {(volume == 0) ? "" : "active"}
      {(volume == 0) ? "" : ((volume > 50) ? "" : "")})
    (volume_children)))

(deflisten volume :initial "50"
  "scripts/bar/volume")
(defwidget volume_children []
  (box :class "reveal_children"
    :orientation "h"
    :space-evenly false
    :halign "center"
    (scale
      :min 0
      :max 100
      :value {volume}
      :orientation "h"
      :onchange "wpctl set-volume @DEFAULT_AUDIO_SINK@ {}%;paplay 'volume.ogg'")))
