Another script that works but likely could be improved. I output to
x11/yad but
x11/xenity
or
x11/xdialog could likely be used.
Quick background:
sndio volume range: 0.000 -> 1.000
sndioctl(1)
yad_sndioctl.sh
Code:
#!/bin/sh
# Modified from rufwoof on Puppy Linux forum
# retrieve sndioctl volume level
SNDIO_VALUE=`sndioctl | grep output.level | cut -d "=" -f 2`
SNDIO_VALUE=`printf "%.2f\n" $SNDIO_VALUE`
# adjust VALUE to 0 to 100 with rounded values
YAD_VALUE=`echo $SNDIO_VALUE*100 | bc`
YAD_VALUE=`printf "%.2f\n" "$YAD_VALUE"`
# Feed YAD_VALUE to yad scale and output to sndioctl
yad --scale --page=2 --window-icon=audio-volume-medium --title="Volume" \
--vertical --on-top --width=32 --height=200 --posx=-134 \
--posy=39 --value=$YAD_VALUE \
--no-buttons --close-on-unfocus --undecorated \
--print-partial | while read x ; \
do x=`echo "scale=2 ; $x/100" | bc`
sndioctl output.level=$x 1>/dev/null ; \
done
I tried using awk but the invocation started with a "0" (zero) value when the script ran and I wondered if the awk value was not an integer? Considered declaring SNDIO_VALUE/YAD_VALUE as integers (int) and using expr rather than echo'ing to bc. Anyone have a online reference for ksh posix compliance? Comments/tweaks appreciated.