Sonos with Linux detailed Howto


Sonos without Windows
I have a Linux server running Debian, a close relation of Ubuntu and a laptop running Ubuntu. I bought a Sonos ZP90 but not the controller. I found various bits and pieces on the internet on how to get this working but no complete howto so I thought it would be useful to others if I created a detailed guide for Google to find :-)

Physical set-up
The Sonos and server are connected to my ADSL modem with ethernet cables. The laptop connects via wireless.

Sharing the music
On the server create a new users sonos
code:
sudo adduser sonos
sudo passwd sonos

and enter a new password.
Check that user sonos can read your music files
code:
su - sonos
cd
ls
cd
ls
exit

check you have Samba installed
code:
dpkg --get-selections | grep samba

If you have it returns
code:
samba-common                                   install

If not install it with
code:
sudo apt-get install samba

Back up the config
code:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.orig

then create /etc/samba/smb.conf to look like this
code:
[global]
workgroup = server
netbios name = server
server string = Samba Server %v
load printers = no
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
interfaces = lo eth0
security = user
password level = 12
username level = 12
encrypt passwords = yes
username map = /etc/samba/smbusers

[musicshare]
path =
valid users = sonos
read only = yes
printable = no
only guest = no

and create a samba users file /etc/samba/smbusers
to look like this
code:
root = administrator admin
nobody = guest pcguest smbguest
sonos = sonos


This next is a new feature for Samba that some of the older howto's didn't need:
code:
sudo smbpasswd -a sonos

and enter a password. This is the one you will use below during the Sonos set-up.

Restart samba to use the new config
code:
sudo /etc/init.d/samba restart


Check it's working
code:
sudo vi /var/log/samba/log.?mbd


Tell Sonos about the music

On the laptop, install Wine
code:
sudo apt-get install wine


Insert the Sonos installation CD, open it with file browser. Right click on setup.exe and choose "open with Wine Windows Program Loader". Follow the usual install instructions. (If the application can't find your Sonos device then try connecting the laptop to your network using an ethernet cable and turn off your wireless connection. This is only necessary for the initial discovery steps.) On the "select music source" page choose "add music stored in folders that are currently shared on my network".
  1. Path: \\server\musicshare (replace "server" with the hostname of your server)
  2. User name: sonos
  3. Password: whatever you typed at the smbpasswd command above

and you should be in business. If not you might get some useful debug from the error message that Sonos gives you.

Web interface

At this point you should be able to play music using the Sonos controller on the laptop running under Wine. However if you have multiple users on your laptop you will have to install it for each of them. For this reason or just because you prefer a web interface you can install the lovely software Sonos web controller.

On the server
code:
wget http://www.purple.org/sonos/sonosweb-0.72.tar.gz

(check that there hasn't been a new release)
code:
tar -xzf sonosweb-0.72.tar.gz
cd sonos
./sonos.pl -config

I you get an error about
code:
Can't locate SOAP/Lite.pm in @INC

then you need to
code:
sudo perl -MCPAN -e "install Data::Dumper"
sudo perl -MCPAN -e "install SOAP::Lite"
sudo perl -MCPAN -e "install LWP::UserAgent"
sudo perl -MCPAN -e "install HTTP::Daemon"
sudo perl -MCPAN -e "install XML::Simple"
sudo perl -MCPAN -e "install HTML::Template"l

which takes a while. Ignore any errors you might get.
For sonos config select the defaults apart from "location on local disk that Sonos indexes" which you should change to point to where you have your music. Install the software
code:
sudo mv sonos /usr/local/share


And now prepare to run it in the background
code:
screen
cd /usr/local/share/sonos
./sonos.pl


If it starts happily then you can do "ctrl-a d" (ie press control and the "a" button at the same time then just the "d" button) to detach from the session and leave it running. To come back to it use
code:
screen -r


On the laptop you should now be able to point a browser at http://server:8001 and away you go!

Good luck,
Dougal

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

50 replies

Userlevel 2
Sonos without Windows
I have a Linux server running Debian, a close relation of Ubuntu and a laptop running Ubuntu. I bought a Sonos ZP90 but not the controller. I found various bits and pieces on the internet on how to get this working but no complete howto so I thought it would be useful to others if I created a detailed guide for Google to find


Note that you can also run the Windows desktop controller with WINE. It works for 95% of the functionality.

What we really need is a cross-platform controller, of course.
Userlevel 2
If you are using ubuntu, do the following:

Install Wine (a guide can be found on the official Wine homepage, google)
Download the Sonos setup file from the main side (what to buy->Controllers->Sonos Desktop Controller for Windows->Download)
Double click the file you downloaded and the install wizard will show
As soon as it is needed, Sonos will prompt you that you need Samba, Ubuntu will guide you through the settings, and you will avoid the need of a password

alot easier, since you completely avoid to use the Console 😛
Userlevel 2

What we really need is a cross-platform controller, of course.


There is a java-based controller than runs on Linux, but it's feature set is quite small, and I haven't had time to work on it much recently...

http://forums.sonos.com/showthread.php?t=10499
Userlevel 2
Badge
I tried the java-based controller on my wife's Ubuntu laptop. It just about worked, but was very sluggish and took multiple double-click and button clicks to get it to play.

I also tried the perl sonosweb solution - before realising that it has to be running on the same box as the music resides (my MP3s are on a Buffalo NAS).

The WINE + Sonos Desktop Controller solution is perfect and works without the hassle of having to configure scripts etc.

Dave
Userlevel 2
I also tried the perl sonosweb solution - before realising that it has to be running on the same box as the music resides (my MP3s are on a Buffalo NAS).


Actually, it doesn't have to be on the same box.

My music is also on a NAS and I used to run sonosweb on a separate machine.
Userlevel 2
Badge
Actually, it doesn't have to be on the same box.

My music is also on a NAS and I used to run sonosweb on a separate machine.

I think I misunderstood.

I'm not very familiar with Linux - during the config of SonosWeb it asks for the directory where the music is so it can index it. I tried putting in the location, which is a samba share, so 'smb://music', but it said that wasn't a directory.

I tried various ways of mounting the location into a normal directory path, and although that seemed to work, SonosWeb still wouldn't do its thing.

Using WINE and SONOS Desktop Controller just worked straight away.

Dave
The Sonosweb app has it's uses, but for a desktop environment, the Sonos native Desktop Controller is far better.

Great you hear you got it working!

Cheers,

Keith
Userlevel 2
Hi dougalf,
I hope you still develop a bit on this one... :)
I'm trying to run your perlscript on one of my servers. After some smaller installation problems I got it to run. But it exists all the time with this error message: "Can't use string ("1") as an ARRAY ref while "strict refs" in use at ./sonos.pl line 1798.". I have tried different "skins" but it is the same error message for most of them. However the simplest skins seams to work...

I hope this makes sense and that you still work on this nice scripts... 🙂
Sorry Snille I've just followed my own HOWTO and I get the same problem as you. I'm very embarrassed. I've fixed the post now but it may be too late for you to recover 😞 I think the problem is that Purple (which I didn't write by the way!) relies on the CPAN rather than the Ubuntu Perl libraries. I patched it up a little by
code:

sudo apt-get remove libsoap-lite-perl libxml-simple-perl

then do it properly
code:
sudo perl -MCPAN -e "install Data::Dumper"
sudo perl -MCPAN -e "install SOAP::Lite"
sudo perl -MCPAN -e "install LWP::UserAgent"
sudo perl -MCPAN -e "install HTTP::Daemon"
sudo perl -MCPAN -e "install XML::Simple"
sudo perl -MCPAN -e "install HTML::Template"l

It takes some time and might give some errors which I just ignored.
It's not perfect because the playlist isn't displayed even though it works fine. I think that the Ubuntu install pulled in some extra perl dependencies but I can't figure out what they are now. I hope you can get this far and that it's good enough for you?

Alternatively you could do
code:
sudo apt-get install mediatomb

I don't remember doing any config. This turns your music into a UPnP media source. The Sonos box is already a media player so all you need is a controller. If you have a Nokia n900 then Zhaan works well although I don't find it as handy for searching as Purple. Perhaps you can find another UPnP controller in the Ubuntu repositories? I'm afraid I don't have time to experiment at the moment.

I know that the person behind Purple used to visit these forums, I don't know if you can get their attention and ask for their help in patching your Perl install....?

Good luck and sorry again,
cheers,
Dougal
Userlevel 2
Hello I'm having a problem setting up my music library. I'm running the sonos desktop controller in wine on ubuntu10.10. The controller can see my zone players and has control over them but cannot set up the music library. I follow the wizard to select my music source; when i add the directory to where i have some music (on the same pc) the wizard responds with a message - " Windows Fire Wall and File sharing - the desktop controller needs to adjust the following windows settings to allow your zone players to access your music files on this computer:" it does not actually list any settings and when i press next the sonos app crashes. I have used samba to share the target music directory (at least i think i have). I know i must be doing something stupid or not doing something obvious so any suggestions would be greatly appreciated. Thanks
Hello I'm having a problem setting up my music library. I'm running the sonos desktop controller in wine on ubuntu10.10. The controller can see my zone players and has control over them but cannot set up the music library. I follow the wizard to select my music source;

The Desktop Controller Music Setup wizard will not work under Wine.

The Wizard basically configures standard Windows Filesharing. It's a shortcut for those who are running windows, but it's not essential. You can do this manually on any OS.

I have used samba to share the target music directory (at least i think i have). I know i must be doing something stupid or not doing something obvious so any suggestions would be greatly appreciated. Thanks


If Samba is set up then you really only need to point Sonos at the shares you have created. To do this from the DTC:

1. Select the "Music" menu

2. Select "Setup Music Library..."

3. In the popup dialogue window click the "Add a share" button

4. In the next page, select "Add music stored in folders that are currently shard on the network" and click "Next >"

5. Enter the path to the share. Note that Browse probably won't work. The format of the path is shown in the dialogue box. You will need to know the share hostname and share name. Also if you have configured secure access, you'll need to enter the username and password here.

(As a hint, if you open a command shell and type "smbtree" then it should list all of the shares on your network. You may need to enter your password).

After that, Sonos should start indexing your music collection.

If you have something other than the Desktop controller, such as an iPod controller or CR200, it's actually easier to use that to set up the music share as the browsing normally works on these.

Cheers,

Keith
Userlevel 2
Bingo! Thank you very much Majik-Keith. I'm up and running. I had been trying 'add music stored on this pc' option as thats where the files were and as nothing showed up when i browsed the network connections i didn't pursue that enough. so thanks for the guidance. - Niallo
Userlevel 2
I just finished following this guide, and ran into some time consuming problems which I finally resolved. I'll list them here so as to possibly help someone else who runs into similar issues.

At the end of the guide, I would type \\server\musicshare into the sonos desktop controller software, but my computer was unable to find the share, or even connect to "server". The command smbtree in the terminal returned nothing.

It turns out the line "interfaces = lo eth0" in the smb.conf file was the root cause. Deleting this entry from the file resolved the problem.

Also, restarting the server using the command mentioned in the guide: "sudo /etc/init.d/samba restart" returned for me "sudo: /etc/init.d/samba: command not found"

The command "sudo service smbd restart; sudo service nmbd restart" on the other hand does work.

Thanks dougalf for the guide, without it I would have probably been at a loss.
Userlevel 2
Is the Web Sonos Controller still maintained? It works, more or less, but there are a lot of errors generated from the perl code. This one happens quite a lot: Can't use string ("1") as an ARRAY ref while "strict refs" in use at ./sonos.pl line 1798. Anybody still using the code, making fixes?
Userlevel 2
Just to let others know, I had a similar problem to that described above with Virtual Box, only in my case with VMWare player. By disabling the VMWare networks, I was able to get the Sonos Desktop Controller to connect with the Sonos Player.

Thanks for the tips that pointed me in the right direction.
Badge +4
After updating to Sonos 3.6, the Purple controller no longer sees any of my zones.

I did a little research ...

The problem seems to be that Sonos no longer uses the URL /xml/zone_player.xml in its UPNP implementation. (Also apparently previously, bridges used /xml/zone_bridge.xml, and this controller used the URL to determine whether or not a device was a zone player.)

Sonos now uses /xml/device_description.xml for both players and bridges.

You can get the Purple controller working by editing sonos.pl, and in the search_cb routine, remove this line:

next if ($device->{LOCATION} !~ /xml\/zone_player.xml/);

Replace with these two lines:

next if ($device->friendlyName !~ /Sonos/);
next if (!($device->friendlyName !~ /Sonos BRIDGE/));

If you are on Windows using the compiled version (.exe), this won't work until somebody updates it. You need to run sonos.pl under perl.exe until this happens.

Here are some quick tips for getting Perl setup on Windows for running this controller.

Download the 32-bit/x86 version of Perl (some support libraries used are not currently available in the Windows 64-bit build).

Issue the following commands to download/setup pre-requisite libraries:

ppm install MinGW
perl -MCPAN -e "install SOAP::Lite"


perl sonos.pl is the command to start the controller.
Userlevel 2
Thanks for the link. However, this does not seem to work with 3.7 😞
Userlevel 2
Thanks for the link. However, this does not seem to work with 3.7 :-(

Since version 3.7, it seems that the Sonos Desktop Controller is relying on a new version of the .NET framework (the errors i get seems to state this reason, i am no pro), and this has caused it to not work under Wine no more :(

I hope the Wine developers will see fit to attempt to fix this in the near future, but the effort they are doing to support as much as they do, must not be underestimated! they amount of work they put into developing this awesome piece of software is incredible!
Userlevel 2
i'm a bit of a wine noob, so didn't really put much effort into fixing this :

knic@crow-t:~/Downloads$ wine SonosDesktopController38.exe
fixme:storage:create_storagefile Storage share mode not implemented.
fixme:storage:create_storagefile Storage share mode not implemented.
wine: Install Mono 2.8 or greater for Windows to run .NET 4.0 applications.
err:msi:ITERATE_Actions Execution halted, action L"InstallFinalize" returned 1627
err:msi:ITERATE_Actions Execution halted, action L"ExecuteAction" returned 1627

Mono is installed on my machine (2.10)


then for the Purple controller:

(after making the havk in the post by skippythelizard.)

Can't call method "subscribe" on an undefined value at ./sonos.pl line 1287.
Userlevel 2
Since version 3.7, it seems that the Sonos Desktop Controller is relying on a new version of the .NET framework (the errors i get seems to state this reason, i am no pro), and this has caused it to not work under Wine no more :(


This may be of some use to you guys.
Hello All,

Not sure if anyone is still looking to get the controller working in Linux, but I was able to get it going by using PlayOnLinux to create a virtual drive. The rough instructions are as follows.

1. Download PlayOnLinux from http://www.playonlinux.com/en/
2. Click on Install
3. At the bottom click on the area to install non listed applications.
4. Install a program in a new virtual drive.
5. Name your virtual drive "Sonos" or whatever you would like.
6. Click on use another version of wine, configure wine, and install some libraries.
7. Click on the newest version of Wine you have listed. The working version for me is 1.5.24.
8. When the next window opens change the Windows version to Windows 8 and then click apply then ok.
9. On the next window select POL_Install_dotnet40
(You may see a crash after this step, just click next and continue, the dot net framework should continue to install)
10. After a bit that should complete and you will be prompted to select a program to run. Select the sonos installer and procede as normal.

That should be it, the program should install just fine. The first thing I notice is the fonts don't look all to great, but messing with any of the font settings so far seem to crash the application. Let me know if anyone has any different results. Hopefully this helps someone else. Please ignore any typos or errors in grammar. I just quickly jotted this down as I went through the process.
Userlevel 2
Hello All,

Not sure if anyone is still looking to get the controller working in Linux, but I was able to get it going by using PlayOnLinux to create a virtual drive.


I see that PlayOnLinux uses WINE, but what does PlayOnLinux add to the mix? I can't tell from the project's site what it actually does.

All of which makes me wonder whether it is, perhaps, merely the newest and latest version of WINE that enables the new breed of DCR to work on Linux. Have you tried the DCR under vanilla WINE 1.5.24?
Userlevel 2
Hello,

I try this evening install wine1.5 on ubuntu
and add dotnet support
code:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.5
winetricks dotnet40


and client controller 4.0 work fine, with some crash, but it's working enough to use it
Userlevel 2
Hello,

I try this evening install wine1.5 on ubuntu
and add dotnet support
code:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.5
winetricks dotnet40


and client controller 4.0 work fine, with some crash, but it's working enough to use it


That's interesting to know.

Which version of WINE are you running? I'm using 1.5.3 here.

I tried this quite some time ago, when the new-look DCR was still in beta. I might have tried again after it was released, but I haven't tried again recently.

When I tried this, I installed .net on my own (i.e. without winetricks) and then the DCR, but it crashed on start.

The DCR has certainly undergone minor changes since then, but I'm wondering whether you're using a newer WINE, too.

The new-look DCR is still classed as garbage on WINE's site, so you might want to update that entry.
Userlevel 2
It's look like to be 1.5.25-0ubuntu1

I use
http://www.ubuntuupdates.org/ppa/wine?dist=precise

After one day, there's some not working tool like adding a samba directory, but as I've also an android phone I can avoid this problem.

It just need a restart after installing dotnet40