scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit 4a509a15f1a24f4106b105cbcbd756ded5688ae9
parent 3224e4733feb802a6e46cbc2a4671dcc655f4340
Author: dsp <dsp@cray.dsplair.2f30>
Date:   Wed,  7 Apr 2021 01:16:27 -0500

updating volume to handle the sndioctl interface since mixerctl is now superuser only

Diffstat:
Mvolume | 31+++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/volume b/volume @@ -2,28 +2,47 @@ #OpenBSD volume control #normalizes the input percentage to 0-255 -printvol() { +#since openbsd 6.7 it attempts to use +#the correct interface (mixerctl/sndioctl) + +printvolmixctl() { currval=$(mixerctl|grep outputs.master\=|awk -F"," '{print $NF}') currval=$(echo $currval "/ 2.55"|bc) echo "Current level:" $currval "%" } +printvolsndctl() { + currval=$(sndioctl|grep output.level\=|awk -F"=" '{print $NF * 100}') + echo "Current level:" $currval "%" +} + usageexit() { typeset -i currval echo "usage:" "$(basename $0) [0-100]" - printvol + if [ $vers -gt 67 ]; then + printvolsndctl + else + printvolmixctl + fi exit } +vers=$(uname -r|tr -d ".") case $1 in +([0-9]) ) if [ $1 -gt 100 -o $1 -lt 0 ]; then usageexit fi - typeset -i volvar - volvar=$(printf "%1.0f" $(echo $1 "* 2.55" |bc)) - mixerctl -n outputs.master=$volvar,$volvar - printvol + if [ $vers -gt 67 ]; then + volvar=$(echo $1|awk '{ print $1 / 100 }') + sndioctl output.level=$volvar + printvolsndctl + else + typeset -i volvar + volvar=$(printf "%1.0f" $(echo $1 "* 2.55" |bc)) + mixerctl -n outputs.master=$volvar,$volvar + printvolmixctl + fi ;; *) usageexit