Tuesday, 5 May 2015

Streaming music via Airplay from Ubuntu to Pioneer VSX-922



So after numerous complaints from my wife that the music setup in our house is not user friendly for her and she can only listen to ad-hoc music from the laptop (as a iPod have a playlist synced to it) I did some research and surprisingly found that pulseaudio had a Airplay module (raop)
The Pioneer amp needed UDP and not TCP streaming as per the native module, so I had to compile and create a icon on the desktop to "click and then listen to music"
That approach is sort of user friendly (still a few clicks to swop between the two pulseaudio versions but it works) next step is to fully automate it.
Installation: 
The complete installation instructions can be found here : http://hfujita.github.io/pulseaudio-raop2/

But the steps are summarised below:


sudo apt-get install build-essential paprefs git pulseaudio-module-raop intltool
sudo apt-get build-dep pulseaudio 
git clone https://github.com/hfujita/pulseaudio-raop2.git
cd pulseaudio-raop2
 ./autogen.sh
  CFLAGS="-ggdb3 -O0" LDFLAGS="-ggdb3" ./configure --prefix=$HOME --enable-x11 --disable-hal-compat
  make  

Thenyou need to configure it to discover AirPlay devices on the network

paprefs &

In the Network Access tab, turn on Make discoverable Apple AirTunes sound devices available locally


Then I wrote a little bash script named "music on amp" with a popup instructing her what to do next.

So currently it is a "guided automation" but it works.

Desktop icon: (music_on_amp.desktop)

[Desktop Entry]
Encoding=UTF-8
Name=Airplay
Comment=Play music to Airplay enabled devices
Exec=/home/user/listen_on_Pioneer.sh
Icon=/home/user/Pictures/airplay.png
Type=Application
Name[en_GB]=Music on AMP

Bash script: (listen_on_pioneer.sh)
#!/bin/bash
# source installed from http://hfujita.github.io/pulseaudio-raop2/
# kill the running pulseaudio
pulseaudio -k
cd ~/pulseaudio-raop2
./src/pulseaudio -n -F src/default.pa -p $(pwd)/src/ &
zenity --info --text 'Dear wife, Please select VSX-922 on next box that will pop up and close' unity-control-center sound
notify-send "Now open Amarok & Enjoy your music my love ..."

I have added a icon & script to change the music back to the laptop (as the Pioneer kept on changing to media source when the laptop send a notification or played music)

Bash script: (listen_on_pc.sh)
#!/bin/bash # kill the running pulseaudio pulseaudio -k
pulseaudio -D # to list the sink # pacmd list-sinks | grep -e 'name:' -e 'index' pacmd set-default-sink 1 pulseaudio -D notify-send "Music will play on PC."

this will kill and start the original pulseaudio and set the source (sink) to the in build speakers.


Monday, 4 May 2015

Sublime Text Mikrotik plugin for text highlighting & auto complete



I had some challenges that I had to resolve on a network (more of that in my next post), and could only access the CLI with the need to see the complete config at once, I used Sublime Text to view the file however having to look at any log or configuration file in one colour is not fun.

Had a quick look and was in luck, there is a Mikrotik Sublime Text plugin, many thanks Kentzo. It can be installed via package manager or be found on Kentzo's Github repository.


The simplest method of installation is through the Sublime Text console as described here. The console is accessed via the ctrl+` shortcut or the View > Show Console menu. Once open, paste the appropriate Python code for your version of Sublime Text into the console.



import urllib.request,os,hashlib; h = 
'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d';
 pf = 'Package Control.sublime-package'; ipp = 
sublime.installed_packages_path(); urllib.request.install_opener( 
urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = 
urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', 
'%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error 
validating download (got %s instead of %s), please try manual install' %
 (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)



After that simply go to Preferences > Package Control > and select install Package; then type the package you want to install.