How to get volume-settings stored.

Problems and successes with specific brands/models of computer audio hardware
Post Reply
Message
Author
Spielmops
Posts: 27
Joined: Tue 12 Dec 2017, 20:25

How to get volume-settings stored.

#1 Post by Spielmops »

Create a new file

Code: Select all

/etc/init.d/rc.local
with this content:

Code: Select all

#!/bin/sh

case "$1" in
 start|restart)
    alsactl -f /etc/asound.state restore #from /etc/asound.state.

 ;;
 stop)
  alsactl -f /etc/asound.state store #saves to /etc/asound.state.
 
esac

###END###
The script "10-alsa" should to this, but it seems buggy.

Spielmops

april

#2 Post by april »

Perhaps a note might explain how this works or should
The scripts in /etc/init.d are executed at bootup and shutdown to start and stop services.

At bootup, the /etc/rc.d/rc.services script will run all executable scripts
found in /etc/init.d, with the commandline parameter 'start'.
At shutdown, the /etc/rc.d/rc.shutdown script will run all executable scriptsfound in /etc/init.d, with the commandline parameter 'stop'.

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#3 Post by rufwoof »

Another option could be to simply read or set the volume level in your own scripts

For getting and setting sound level rather than a panel volume control I create a yad (gtk look) volume slider window ... for instance in OpenBSD :

Code: Select all

#!/bin/sh
GEO="--geometry 40x204-0+64"
# retrieve current volume level
VALUE=`mixerctl outputs.master | awk 'BEGIN { FS = "," } ; { print $2 }'`
# adjust 0 to 255 scaled to 0 to 100 and rounded
VALUE=`echo $VALUE/2.55 | bc`
VALUE=`printf "%.0f\n" "$VALUE"`
yad --scale --vertical --title="Vol " $GEO --value=$VALUE --no-buttons --print-partial | while read x ; do x=`echo $x*2.55 | bc`; x=`printf "%.0f\n" "$x"`;mixerctl -q outputs.master=$x ; done
For amixer (my Debian install) that is alsa based instead of mixerctl I use
amixer get Master ... and amixer set Master .... (which IIRC uses 0% to 100% values so I revise the above script to not bother with the 0..255 ranging that mixterctl uses)

In OpenBSD when using twm window manager and in cases where I don't have yad installed I create a twm sub menu

Code: Select all

menu "Volume" 
{
   	"Volume"								f.title
   	"   0%"      	( "#00B6FF" : "black"   	) 	!"mixerctl -q outputs.master=0"
   	"   5%"      	( "#00B6FF" : "black"   	)  	!"mixerctl -q outputs.master=13"
   	"  10%"      	( "#00B6FF" : "black"  	)  	!"mixerctl -q outputs.master=26"
   	"  15%"     	( "#00B6FF" : "black"  	)  	!"mixerctl -q outputs.master=38"
   	"  20%"      	( "#00B6FF" : "black"  	)  	!"mixerctl -q outputs.master=51"
   	"  25%"      	( "#00B6FF" : "black"  	)  	!"mixerctl -q outputs.master=64"
   	"  30%"      	( "#00B6FF" : "black"  	)	!"mixerctl -q outputs.master=77"
   	"  35%"      	( "green" : "black"       	)  	!"mixerctl -q outputs.master=89"
   	"  40%"      	( "green" : "black"       	)  	!"mixerctl -q outputs.master=102"
   	"  45%"      	( "green" : "black"       	)  	!"mixerctl -q outputs.master=115"
   	"  50%"      	( "green" : "black"       	)  	!"mixerctl -q outputs.master=128"
   	"  55%"      	( "green" : "black"       	)  	!"mixerctl -q outputs.master=140"
   	"  60%"      	( "green" : "black"       	)	!"mixerctl -q outputs.master=153"
   	"  65%"      	( "green" : "black"       	)	!"mixerctl -q outputs.master=166"
   	"  70%"      	( "red" : "black" 	        )	!"mixerctl -q outputs.master=179"
  	"  75%"      	( "red" : "black" 	        )	!"mixerctl -q outputs.master=191"
   	"  80%"      	( "red" : "black" 	        )	!"mixerctl -q outputs.master=204"
   	"  85%"      	( "red" : "black" 		)	!"mixerctl -q outputs.master=217"
   	"  90%"      	( "red" : "black" 		)  	!"mixerctl -q outputs.master=230"
   	"  95%"      	( "red" : "black" 		)  	!"mixerctl -q outputs.master=242"
   	" 100%"     	( "red" : "black" 		)	!"mixerctl -q outputs.master=255"
}
.... just a couple of example of how amixer or mixerctl can be used within your own script instead of having to rely upon a system script.

Spielmops
Posts: 27
Joined: Tue 12 Dec 2017, 20:25

#4 Post by Spielmops »

@rufwoof: yes, very good: Why should I do this easy, if there is a much more complicated solution ....

Spielmops

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#5 Post by nic007 »

Depends how you run Puppy. If frugal with savefile/folder, it will be saved automatically. Anyways the command:

Code: Select all

alsactl store
should do the necessary.
BTW - The default builtin remaster program does not save your customised volume settings so if you are going to use that, run the abovementioned command first before doing a remaster (I've included it in my remaster suite which has been published here: http://www.murga-linux.com/puppy/viewto ... 779#958779)

Post Reply