How to launch two instances of spotify at the same time on linux


I have a PC at home that works as an entertainment center. I run spotify on it and control it with my smartphone so I don't even have to turn on the monitor to listen to my tunes.

However, I'm not alone at home and I'd like my SO to be able to do that too, without having to log in and out of spotify all the time.

I triede creating a separate user account and run it as that with gksudo but I ran into a number of permission issues. I was able to run it by doing xhost + but it still was unable to play music.

The next step was to just override $HOME, which worked, but when I tried to launch the second instance, it just surfaced the already running window and complained about a link not found

It turned out that the new instance communicates with the running one via dbus. I came across this idea reading this question on stackoverflow. However on Ubuntu trusty, the command that runs a program in a separate dbus session is dbus-launch rather than dbus-run-session.

So if you want to run two spotifies just create a file named spotify2 with the following content and make it executable.

mkdir -p ~/.althome
export HOME=/home/althome
dbus-launch spotify

Put it in $HOME/bin, chmod +x it and reboot. Then you can add it to your startup applications.