Hopefully the information in here is useful to you (if it isn't please get in touch!).
If you want to get the new stuff as soon as it's out though, sign up to the mailing list below.
tldr; I wrote a small script in python to use alsa command line tools to change the volume on my headset. A tool already exists that if faster and more robust. I should switch, but will I? who knows :).
I own and (mostly) happily use a Logitech G930:
While the support under linux is pretty good already (most buttons work, and perform their intended functions), I recently got fed up with the fact that the little scroll wheel on the G930 wasn’t actually changing the volume. Currently I can modify the volume of the headset through the ever-amazing Pulse Audio Volume Control (pavucontrol) application, but the actual on-headset scroll wheel isn’t working, and it’s a bit frustrating.
While there is probably some bit of configuration (hopefully) that could perform the mapping of my individual setup of ALSA+PulseAudio to correctly catch the
XF86AudioLowerVolume buttons and increase/decrease the volume on the headphones, I decided this would be a good time to hack up a solution. In this case, the solution requires a few steps:
Of course, #2 is very easy to accomplish by looking in Arch’s keyboard customization menus (Keyboard > Application Shortcuts), so that’s not the part we’re going to talk about today. Doing #1 was a great way to practice Python (and realize how much of it I’ve forgotten), and was a great exercise in writing a small but effective script to utilize available system binaries (the binaries that I didn’t write do the actual hard work of talking to the headset, of course).
After some digging and internet-searching, I found the magical command that would properly change the volume on my headset:
$ amixer -c 2 cset numid=4 50%
This command has a few facets, but the important things to note are:
csetis the subcommand used to set the property that represents the volume
numid=4bit gets the right property that corresponds to the volume that the headset is producing
The task broke down into a few simple sub-tasks:
aplay -l to get the sound card number of the device that represents the headset.
amixer to gather information, and find out how I can identify the property/control I actually want.
Generate a shell command that uses
amixer cset to set that property somewhat intelligently.
I’ll cut to the chase and post the Github snippet of the finished product here:
All in all, it was a fun little task to complete, and it gave me a little bit more knowledge on how to debug arch when it has issues with sound, which was fantastic.
As per usual, right after finishing this little script (while actually writing this blog post), I stumbled upon pamixer, which of course reduces all the effort I put forth to a proper command line tool with a good API and documentation:
$ pamixer -d 5 --sink 1
pamixer also came with extremely easy to use commands to determine which sinks and sources are available.
Now, I only need to decide if the last few hours were completely in vain or not.