I need to change my volume on my USB sound card (which is the default card) via the command line. I know alsamixer
will do that but I need it to be a one line command so I can use it in a python script, e.g., os.system("volume up 1")
, or something like that. Is there any way to do this?
1 Answer
Create a Bash file with the following code:
amixer scontrols amixer sset 'Master' 50%
Make the Bash file executable using
chmod +x filename
In Python, use the following:
import os os.system("directorytobashfile/file")
-
-
-
-
amixer scontrols
just prints the list of controls. And why don't you executeamixer
directly?– CL.Oct 10, 2015 at 8:09 -
@CL. Sorry I just do that to make sure I have the right command. I don't execute it directly because this way he can add to the bash file. You could do it directly too! Oct 10, 2015 at 15:42
pyalsaaudio
(check withapt-cache search alsa | grep python
). That will mean reading the API docs a bit, so not as easy asos.system()
.