22 October 2015

Pulseaudio server in Docker container

The full title should actually read Pulseaudio server in docker container on Raspberry PI 2, but this doesn't really matter.

In short here it is:

Now everything one by one:
  • docker run --rm -ti - run non-persistent docker and prepare it as interactive (shell) run
  • --device=.... make local sound devices available in container. This feature is quite new in docker, so make sure you have recent version (mine is 1.8)
  • -p 4713:4713 set up port forwarding between host and container to make pulse server available to clients 
  • rpi-deb-pulse is my docker image built from armbuild/debian by running system upgrade and install pulseaudio
  • /bin/bash -c "..." is command to run inside container, more on this below
  • groupadd --gid $(...) alsadev create a group inside container named alsadev and having same id as group of /dev/snd/controlC0 device. We need this to allow pulse to access native alsa devices.
  • $(ls -l /dev/snd/controlC0 | cut -d' ' -f4 | xargs getent group | cut -d: -f3) this subshell is executed on host, not in container and prints group id of /dev/snd/controlC0
  • gpasswd -a pulse alsadev adds user pulse to our new group alsadev
  • pulseaudio ... run pulseaudio
  • -L 'module-alsa-sink device=hw:0,0' explicitly load alsa sink and specify which output to use
  • -L 'module-native-protocol-tcp auth-ip-acl=' load tcp protocol listener and (optionally) configure ip-acl to only accept connections from given subnet

How to then use it to play sound remotely (client):
  1. pactl load-module module-tunnel-sink server=
  2. in pavucontrol on Playback tab select desired sink for a stream
Things to improve:
  • list of devices may be replaced with another subshell to not specify each dev manually
  • add systemd unit to start container automatically
  • tune pulseaudio since sound over tcp tunnel is worse then playing locally
Why was this done :)
I have a Raspberry Pi 2 acting as a wireless router and i didn't wont to install pulse into host system. And i was just curious about whether this will work :)

09 March 2015

Seesu.me, dwb & vk.com

Rather a useless post, but it was fun for me to find all these out.

The story

seesu.me is an awesome online media player or radio or whatever you call it. Just give it try.
dwb is a minimalistic vim-imsnpired browser.
And vk.com is popular (at least in xUSSR countries) social network.

What brings them all here is that there is large music collection available on vk.com which can be very nicely listened to with seesu.me. But me problem was that vk login button wasn't working in dwb browser.

The solution

In short i needed to do the following:
  1. open dev console (dwb is based in webkit, so there is on) to find the login button
  2. check if clicking on it programatically would work
  3. if yes, all done - i'll login to vk, login will be remembered and nothing to worry about
Pressing standard Ctrl+Shift+I didn't worked. With google on my hands i found man 1 dwb which states that enable-developer-extras need to be enabled. I had no idea what it was, playing with command completion in dwb itself didn't helped as well. Again googling i found that option in ~/.config/dwb/settings (close dwb, then edit and save the file, then run browser again).

After that dev console popped up on :wi command, but unfortunately each time it shows up it crashes the whole browser.

I had to pick firefox to check if triggering click programmatically would do the trick and it really did. Invoking $('.sign-in-to-vk').click() in dev console was at least triggering popup blocker and then i was able to reach the popup (BTW popup blocker was veeery important here).

Back to dwb i needed a way to execute arbitrary JS on a page which was quickly and easily found in already opened man page. So on seesu page i typed :js $('.sign-in-to-vk').click() and nothing happened again. Here i remembered about popup blocker and (quickly again) found and option javascript-can-open-windows-automatically which was set to true with ss javascript-can-open-windows-automatically true

After that repeating JS snipped worked like a charm.

12 January 2015

Adventures with Asus P8H61-M LE/USB3 and UEFI boot

On Friday i've broken my boot loader tying to migrate to UEFI and today i was looking forward to fix and get UEFI working! But that wasn't the case.
My PC booted in UEFI mode from Achlinux USB pendrive i've brought from home, but i rejected to boot from HDD.
I don't know how much time would i spent with this, but fortunately our sysadmin guys passed through and noticed me messing about BIOS. That appeared to be a know issue of my motherboard. The version i had was 0306.

I won't provide you with detailed instruction on how to upgrade you BIOS! The only hint i may give you - prior to doing this do reset all setting to defaults.

Now all works for me :)