DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 2nd December 2022
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default Script for yad (zenity,xdialog) Audio volume slider

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.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT. The time now is 03:39 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick