Nicolas Neu

dies & ditt.

Volumecontrol via Web

You know what the cloud is good for? Filesyncing, mail, listening to music and a bit of recreational netflix’ing now and then. You know what it isn’t good for? Adjusting the volume of your living room linux server which is hooked up to the television and every time you sit down to watch some Doctor Who you just slightly misjudge the mid-episode volume level and now you either have to endure this situation for the next 35 minutes or you have to get up from the couch. Both of which sounds subpar.

Well, fret no more. I threw a small webservice together over the weekend which provides a simple webinterface to increase and decrease the volume on any linux pc. As long as they are using ALSA audio which I admit might pose a problem. My server is running lubuntu which still uses ALSA but one could probably make it work for Pulseaudio. A Running Pulseaudio server can be controlled with pactl, so setting the volume can be done with a system call, e.g.:

pactl set-sink-volume 0 -- -5%    

Although I don’t really know how to get the current volume level, but one could probably go without that.

You can find the code on GitHub. If you don’t already have flask and the Python ALSA bindings you can install them and run the server with the following commands:

pip install flask
sudo apt-get install python-alsaaudio