Skip to main content
3 of 4
Grammar, indentation and some upper-, lower-casing corrected.

amixer sset 'Master' 50% works on terminal but not as os.system command

I'm trying to write a python program on my Raspberry Pi to mute/change the volume of the speaker output as soon as it runs. If I type:

amixer sset 'Master' 50%

on the terminal, the volume is increased by 50%.

However if I write a python file called filename.py with the following lines:

import os
os.system(amixer sset 'Master' 50%)

and run it in terminal with

sudo python filename.py

it comes up with an error

amixer: Unable to find simple control 'Master',0

How can I just run exactly the same command in terminal as I do in python?

mnt
  • 93
  • 7