Eww volume slider widget help

eww.yuck slider module

(defwidget volume []
    (box :orientation "h" :valign "start" :class "vol_slider"
        (scale :min 0 :max 101 :value {volume} :onchange "wpctl set-volume @DEFAULT_AUDIO_SINK@ {}")
    )
)
(defpoll volume :interval "1000ms" "~/.config/eww/scripts/get_vol")

get_vol script:

wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}'

the output of the script:

0.06

the error:

26 │         (scale :min 0 :max 101 :value {volume} :onchange "wpctl set-volume @DEFAULT_AUDIO_SINK@ {}")
   │                                        ────── `` is not of type `f64`
   │
   → cannot parse float from empty string

its not empty though, its anywhere from 0.00 to 1.00. it doesnt make any sense to me because its not an empty float at all

also my volume goes to 1000% when i use the slider, its horrible

i found this on git hub and the author marked it as the answer but i dont understand what it means:

”No initial value so if the window renders before the first poll the error appears, you can set one or just ignore these (unless they appear even after the first poll)”

My guess is that wpctl seems to expect your volume percentage as a decimal value between 0:1 → 0%-100% volume but you supply between 0:101 → 0%-10000% volume. So whenever you use the slider it will take your percentage as an int instead of a decimal which will 100x your desired input.

It basically means you try to use the volume value before the script has retrieved it. Should be fixable by setting an initial value for your volume.

`:initial “0.0”` in your defpoll or smth like this

im not sure how i got it to work but im afraid to touch it again lol