Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 24 lines (17 sloc) 622 Bytes
#!/usr/bin/env python
# Set the volume louder or softer, depending on program name.
from __future__ import print_function
import alsaaudio, sys, os
increment = 4
# First find a mixer. Use the first one.
try :
mixer = alsaaudio.Mixer('Master', 0)
except alsaaudio.ALSAAudioError :
sys.stderr.write("No such mixer\n")
sys.exit(1)
cur = mixer.getvolume()[0]
if os.path.basename(sys.argv[0]).startswith("louder") :
mixer.setvolume(cur + increment, alsaaudio.MIXER_CHANNEL_ALL)
else :
mixer.setvolume(cur - increment, alsaaudio.MIXER_CHANNEL_ALL)
print("Volume from", cur, "to", mixer.getvolume()[0])