I need to script playing a sound. Think https://www.youtube.com/watch?v=cl0EI44nMXE&t=37s
The catch is I need it to play regardless of if the system is muted or the sound is turned low, and allow executing the command repeatedly/quickly.
An acceptable solution could save, play, and restore volume irrespective of other system events - but it needs to work if the command is executed multiple times overlapping itself. Eg:
@time=0 @time=[after]
vol=10% volume=10% preserved
V v
|--no--|
|--no--|
|--no--| ...
my system is ubuntu20.04, using alsa. Bash shell would be preferred if the result is understandable for mere humans; else perhaps python? For reference, the following work as expected on their own (and installing programs available in normal repos is OK).
amixer -q -D pulse sset Master 20%+ # volume increase
amixer -q -D pulse sset Master toggle # toggles mute
play no.mp3 # SoX play mp3