![]() |
|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
![]() |
|
Thread Tools | Display Modes |
|
|||
![]()
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 |
|
|||
![]()
Thanks. When I stepped through it last night, awk would pull the value but I'm not sure the numeric manipulations were working fully. x11/yad would display a volume level and the slider would be set to "0" even though music was audible. Using the slider would adjust volume.
Code:
#!/bin/sh sndio_value=$(sndioctl output.level | awk -F'=' '{print $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=-174 \ --posy=49 --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 Last edited by shep; 4th December 2022 at 10:52 PM. Reason: Lower case for script variables to distinguish from SYSTEM_VARIABLES |
|
||||
![]() Quote:
And I forgot to answer this: Quote:
For an overview of the POSIX shell specification see https://pubs.opengroup.org/onlinepub...V3_chap02.html More generally, I like to use https://shellcheck.net to pick up problems in shell scripts. It will detect any deviations from POSIX compliance in /bin/sh scripts. Last edited by Head_on_a_Stick; 2nd December 2022 at 09:38 PM. Reason: removed erroneous statement about OpenBSD's sh(1) |
|
|||
![]()
Thanks. My shell scripting has largely been searching for a specific function and then adapting it. I'm also about 200 pages into a book on shell scripting which is pretty generic and is more bash than ksh.
|
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Volume Control (in Java) | mattthumper | Programming | 1 | 6th August 2015 03:23 PM |
Systray Audio Volume control | shep | OpenBSD Packages and Ports | 2 | 30th April 2013 02:29 PM |
azalia Intel SCH HD Audio strange audio issues | tehsean | OpenBSD General | 3 | 26th August 2012 12:21 AM |
shell script with zenity | bsdnewbie999 | OpenBSD General | 5 | 24th April 2009 02:37 AM |
MS DOS volume labels? | bigearsbilly | FreeBSD General | 2 | 1st April 2009 10:50 PM |