Difference between revisions of "Spotify"

From ArchWiki
Jump to: navigation, search
(Global Media Hotkeys)
(Troubleshooting: Add note on CEF bug)
 
(108 intermediate revisions by 54 users not shown)
Line 1: Line 1:
[[Category:Audio/Video]]
+
[[Category:Multimedia players]]
 
[[Category:Wine]]
 
[[Category:Wine]]
 +
[[ja:Spotify]]
 
[http://www.spotify.com/ Spotify] is a digital music service that gives you access to millions of songs.
 
[http://www.spotify.com/ Spotify] is a digital music service that gives you access to millions of songs.
  
This Internet music service allows you to select any song in its database and stream for free. The service was recently introduced to the United States after previously being exclusive to Europe. The Linux client is only officially packaged for Debian and Fedora distributions, but is also available in the AUR: {{AUR|spotify}}. Officially, they recommend that Linux users run the windows client under Wine. The only catch to using this application as a free user is the inability to go mobile without a premium subscription. There are also the occasional voice ads in between songs for users who do not wish to subscribe.
+
This Internet music service allows you to select any song in its database and stream for free. The service was recently introduced to the United States after previously being exclusive to Europe. The Linux client is only officially packaged for Debian and Fedora distributions, but is also available in the AUR: {{AUR|spotify}}. Officially, they recommend that Linux users run the windows client under Wine. There are also the occasional voice ads in between songs for users who do not wish to subscribe.
  
 
Spotify also offers free users the ability to create playlist which can be shuffled, and set to repeat tracks. Content provided by Spotify comes in explicit versions as well as censored.
 
Spotify also offers free users the ability to create playlist which can be shuffled, and set to repeat tracks. Content provided by Spotify comes in explicit versions as well as censored.
  
 +
== Installation ==
  
== Installing The Client ==
+
Choose which client you would prefer. The Linux client is receiving good reviews. However, if you are comfortable with wine and its configuration, you might want to choose the windows client. Please note that you do '''not''' need to install both. There is also the online player (requires flash) on https://play.spotify.com/.
Choose which client you would prefer. The Linux client is receiving good reviews. However, if you are comfortable with wine and it's configuration, you might want to choose the windows client. Please note that you do NOT need to install both.  
+
  
=== Installation of Linux Client ===
+
There are also some alternatives to the official spotify client:
Follow the instructions for installing packages from the AUR: https://wiki.archlinux.org/index.php/AUR#Installing_packages and install the AUR package here: {{AUR|spotify}}. The pkgbuild will automatically download the software. It would be a good use of time to go to the spotify website and create your user account while it's building.
+
If you wish to play local files you will need to install {{AUR|ffmpeg-spotify}} as well.
+
You can also install {{AUR|spotify-gnome-git}} to control spotify with gnome's media keys.
+
  
=== Installation of Windows Client using Wine===
+
* {{App|[[Wikipedia:Clementine_(software)|Clementine]]|Amarok 1.4 clone, ported to Qt 4, is able of streaming from Spotify with a premium account after activating (downloading) a plugin in the settings.|http://www.clementine-player.org/|{{Pkg|clementine}}}}
 +
* {{App|[https://www.mopidy.com/ Mopidy]|An alternative plug-in based implementation of [[Music Player Daemon]] is able of streaming from Spotify with an extension.|https://github.com/mopidy|{{Pkg|mopidy}}+ {{AUR|mopidy-spotify}} or {{AUR|despotify-svn}}}}
  
==== Install Wine ====
+
=== Linux ===
First, you must ensure that you have [[Wine]] installed on your system. In addition to installing Wine you will need to take a moment to configure it for the user who will be running the application.
+
  
Depending on your choice of architecture it may be necessary for you to enable the [[Official_Repositories#.5Bmultilib.5D|multilib]] repositories. This is necessary to install Wine on x86_64 systems, if not enabled [[pacman]] will inform you that the package was not found.
+
{{AUR|spotify}} from the [[AUR]] will automatically download the software. If you wish to play local files you will need to install {{Pkg|ffmpeg0.10}} as well.
  
# pacman -Syy
+
=== Windows (Wine) ===
# pacman -S wine wine_gecko
+
  
==== Configure Wine ====
+
See [[Wine]].
  
When wine is installed you will need to change some configuration settings using the winecfg application on your every day user account (not root).
+
Obtaining Spotify can be done by registering for an account on their Website, the application does not offer in-app registration. However you can obtain the application prior to registering by using the following URL. [http://download.spotify.com/Spotify%20Installer.exe]
 
+
$ winecfg
+
 
+
After launching the winecfg application you will be presented with multiple tabs that can assist you in tweaking the performance of the emulator. However for this purpose your main focus will be the Audio tab.
+
 
+
While under the audio tab, you will enable either the ALSA or OSS driver by clicking the check box next to them, depending on what software you prefer to use. Also note that the hardware acceleration will need to be changed from Full to Emulation. When done you may exit the winecfg application.
+
 
+
Failure to perform the above task will result in the inability to hear playback.
+
 
+
==== Run Installer ====
+
 
+
Obtaining Spotify can be done by registering for an account on their Website, the application does not offer in-app registration.
+
 
+
However you can obtain the application prior to registering by using the following URL. [http://download.spotify.com/Spotify%20Installer.exe]
+
  
 
After you have registered and downloaded your copy of the installer you will need to run the application through Wine, depending on your setup you may be able to run the application by right clicking the file. If not terminal will work just fine, as long as you run the below command in the directory of your download.
 
After you have registered and downloaded your copy of the installer you will need to run the application through Wine, depending on your setup you may be able to run the application by right clicking the file. If not terminal will work just fine, as long as you run the below command in the directory of your download.
Line 50: Line 33:
 
Once the application is successfully installed you may run Spotify by using one of the following commands in terminal, or in the ALT+F2 launcher:
 
Once the application is successfully installed you may run Spotify by using one of the following commands in terminal, or in the ALT+F2 launcher:
  
If you use a x86_64 copy of ArchLinux, you'll have to run it like this:
+
If you use a x86_64 copy of ArchLinux, you will have to run it like this:
  
 
  $ wine "/home/username/.wine/drive_c/Program Files (x86)/Spotify/spotify.exe"
 
  $ wine "/home/username/.wine/drive_c/Program Files (x86)/Spotify/spotify.exe"
Line 60: Line 43:
 
If you have any additional problems, I recommend setting the winecfg to Windows XP or Windows 7 emulation.
 
If you have any additional problems, I recommend setting the winecfg to Windows XP or Windows 7 emulation.
  
==Global Media Hotkeys==
+
== Global media hotkeys ==
  
Spotify has support for media keys like {{ic|XF86AudioPlay}}, but out of the box they only work inside Spotify. We can use for example [[xbindkeys]] to catch the global media keypresses, and then forward them to Spotify using one of the methods below.
+
Spotify has support for media keys like {{ic|XF86AudioPlay}}, but out of the box they only work inside Spotify. We can use for example [[xbindkeys]] to catch the global media keypresses, and then forward them to Spotify using one of the methods below. If you use xbindkeys, ensure that Spotify is restarted after installation and key configuration otherwise the key events will not be properly caught.
 +
 
 +
=== Linux ===
 +
 
 +
==== MPRIS ====
 +
 
 +
The Spotify client implements the [https://specifications.freedesktop.org/mpris-spec/latest/ MPRIS2 ] D-Bus interface which allows external control.
 +
 
 +
===== Playerctl =====
 +
 
 +
The {{aur|playerctl}} utility provides a command line tool to send commands to MPRIS clients. The only commands you will likely need to bind globally are {{ic|play-pause}}, {{ic|next}} and {{ic|previous}}
 +
 
 +
$ playerctl play-pause
 +
$ playerctl next
 +
$ playerctl previous
 +
 
 +
Playerctl will send the command to the first player it finds, so this method will also work with others players such as [[vlc]]. To ignore other players, pass {{ic|--player=spotify}} as an argument.
 +
 
 +
===== D-Bus =====
 +
 
 +
An alternative to the above is to manually use [[D-Bus]], which should be available by default as it is a dependency of [[systemd]].
 +
 
 +
To play or pause the current song in Spotify:
 +
 
 +
$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
 +
 
 +
In order to bind this and the other commands to the media keys you need to install [[Xbindkeys]] and edit your .xbindkeysrc and add the following lines:
 +
 
 +
# Play/Pause
 +
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
 +
XF86AudioPlay
 +
 +
# Next
 +
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
 +
XF86AudioNext
 +
 +
# Previous
 +
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
 +
XF86AudioPrev
 +
 +
# Stop
 +
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
 +
XF86AudioStop
 +
 
 +
If the above commands do not work, try setting the dbus address:
 +
 
 +
  USER=`whoami`
 +
  PROCESS=spotify
 +
  PID=`pgrep -o -u $USER $PROCESS`
 +
  ENVIRON=/proc/$PID/environ
 +
  if [ -e $ENVIRON ]
 +
  then
 +
      export `grep -z DBUS_SESSION_BUS_ADDRESS $ENVIRON`
 +
  else
 +
      echo "Unable to set DBUS_SESSION_BUS_ADDRESS."
 +
      exit 1
 +
  fi
 +
 
 +
==== xdotool ====
  
===Using a bash-script and xdotool===
 
 
With the help of {{ic|xdotool}} it is possible to send your hotkeys to the application. The following script is an example of how to control Spotify from the outside:
 
With the help of {{ic|xdotool}} it is possible to send your hotkeys to the application. The following script is an example of how to control Spotify from the outside:
 +
 
  #!/bin/sh
 
  #!/bin/sh
 
   
 
   
Line 83: Line 124:
 
         ;;
 
         ;;
 
  esac
 
  esac
  xdotool key --window $(xdotool search --name "Spotify (Premium )?- Linux Preview"|head -n1) $key
+
  xdotool key --window $(xdotool search --name "Spotify (Premium |Unlimited |Free )?- Linux Preview"|head -n1) $key
 
  exit 0
 
  exit 0
  
Let's call it {{ic|musickeys.sh}}. Make the script executable:
+
Let us call it {{ic|musickeys.sh}}. Make the script executable:
 +
 
 
  $ chmod +x musickeys.sh
 
  $ chmod +x musickeys.sh
By executing {{ic|./musickeys.sh play}} you can now toggle playing a song. Now you can bind this script to any tool that catches keypresses, such as [[xbindkeys]]. For [[Openbox]] you can use the following example (see [[Openbox#Configuration]] for help):
 
<keybind key="XF86AudioPlay">
 
  <action name="Execute">
 
      <execute>~/bin/musickeys.sh play</execute>
 
  </action>
 
</keybind>
 
<keybind key="XF86AudioNext">
 
  <action name="Execute">
 
      <execute>~/bin/musickeys.sh next</execute>
 
  </action>
 
</keybind>
 
<keybind key="XF86AudioPrev">
 
  <action name="Execute">
 
      <execute>~/bin/musickeys.sh prev</execute>
 
  </action>
 
</keybind>
 
  
===D-Bus===
+
By executing {{ic|./musickeys.sh play}} you can now toggle playing a song. Now you can bind this script to any tool that catches keypresses, such as [[xbindkeys]].
  
An alternative to the above is [[D-Bus]], which should be available by default as it is a dependency of [[systemd]]. With D-Bus we have a consistent and reliable way to communicate with other processes, such as Spotify.
+
===Windows ===
To play or pause the current song in Spotify:
+
$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
+
  
In order to bind this and the other commands to the media keys you need to edit your .xbindkeysrc and add the following lines:
+
If you prefer the wine-version of Spotify, you can use {{AUR|spotifycmd}}{{Broken package link|{{aur-mirror|spotifycmd}}}} to send actions to Spotify. [https://github.com/Tarrasch/dotfiles/compare/0149505f%5E...19ede1f6 Here] is a sample setup of xmonad bindings using spotifycmd.
# Play/Pause
+
 
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
+
== Tips & Tricks ==
  XF86AudioPlay
+
 
 +
=== Disable track notifications===
 +
 
 +
{{note|It is worth noting that if you have a {{AUR|SpotCommander}} [http://olejon.github.io/spotcommander/ Server] running alongside Spotify, and you disable track notifications by following the instructions below, the [https://play.google.com/store/apps/details?id&#61;net.olejon.spotcommander&hl&#61;en SpotCommander Client] running on your mobile device will display that “No Music is Playing” and will [http://askubuntu.com/questions/472325/remove-spotify-pop-up-notification-when-a-song-starts/472329#472329 fail to display track info] such as title, artist, album art, etc. Apart from that, the mobile client still works fine though, and is still able to skip, play, pause, control volume, etc.}}
 +
 
 +
After version 0.9.10, track change notifications were enabled by default. They can be quite intrusive. To disable them, add the following line to {{ic|~/.config/spotify/Users/<spotifylogin>-user/prefs}}
 +
 
 +
  ui.track_notifications_enabled=false
 +
 
 +
It is also possible to launch spotify with the {{ic|--ui.track_notifications_enabled&#61;false}} option.
 +
 
 +
=== Show track notifications===
 +
 
 +
{{AUR|playerctl}} provides a library you can use with {{pkg|python-gobject}} and a notification daemon such as {{pkg|dunst}} to show the artist and title in a notification when the track changes.
 +
 
 +
  #!/usr/bin/env python3
 
   
 
   
  # Next
+
  from gi.repository import Playerctl, GLib
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
+
  from subprocess import Popen
  XF86AudioNext
+
 
   
 
   
  # Previous
+
  player = Playerctl.Player()
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
+
XF86AudioPrev
+
 
   
 
   
  # Stop
+
def on_track_change(player, e):
  "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
+
    track_info = '{artist} - {title}'.format(artist=player.get_artist(), title=player.get_title())
  XF86AudioStop
+
    Popen(['notify-send', track_info])
 +
 +
player.on('metadata', on_track_change)
 +
 +
GLib.MainLoop().run()
 +
 
 +
=== Skip overplayed radio tracks===
 +
 
 +
Another use of the {{AUR|playerctl}} library is to skip tracks that are played too much on radio when you do not necessarily want to downvote these tracks because you may want to hear them again later on that station.
 +
 
 +
  #!/usr/bin/env python3
 +
   
 +
from gi.repository import Playerctl, GLib
 +
 +
player = Playerctl.Player()
 +
 +
played_out = ['Zu Fuss', 'Walk And Talk', 'Neuland']
 +
 +
def on_track_change(player, e):
 +
    if player.get_title() in played_out:
 +
        player.next()
 +
 +
player.on('metadata', on_track_change)
 +
 +
GLib.MainLoop().run()
 +
 
 +
=== Mute commercials ===
 +
 
 +
==== blockify ====
 +
 
 +
With [https://github.com/mikar/blockify blockify] you can mute commercials. It is available in the [[AUR]] as {{AUR|blockify}}.
 +
 
 +
To have this start and run in the background every time Spotify starts you will need to automate this yourself:
 +
 
 +
{{bc|<nowiki>
 +
#!/bin/sh
 +
 
 +
spotify=/usr/bin/spotify
 +
 
 +
if [[ -x $spotify && -x /usr/bin/blockify ]];
 +
then
 +
  blockify &
 +
  block_pid=$!
 +
  $spotify
 +
  trap "kill -9 $block_pid" SIGINT SIGTERM EXIT
 +
fi
 +
</nowiki>}}
 +
 
 +
By placing this script at {{ic|/usr/local/bin/spotify}}, it gets preferred to {{ic|/usr/bin/spotify}} everytime you start Spotify, so there's nothing else to change and updates won't break it.
 +
 
 +
==== spotblock ====
 +
 
 +
[https://github.com/mahkoh/spotblock spotblock] ({{AUR|spotblock-git}}) is a resource-efficient ad blocker that runs as a systemd daemon.
 +
 
 +
==== Spotify-AdKiller ====
 +
 
 +
[https://github.com/SecUpwN/Spotify-AdKiller Spotify-AdKiller] ({{AUR|spotify-adkiller}}) is another alternative to block Spotify adds.
 +
 
 +
=== Remote Control ===
 +
 
 +
==== Send commands via SSH ====
 +
 
 +
If you set up ssh on the server, you can send controls from a client to a remote Spotify instance with
 +
 
 +
$ ssh user@host ''yourcommand''
 +
 
 +
where ''yourcommand'' can be [https://code.google.com/p/spotifycmd/ spotifycmd] that you installed on the server, or a dbus script for the linux version, as described above.
 +
 
 +
==== Grab the Spotify window via SSH ====
 +
 
 +
Aside from grabbing the whole desktop with TeamViewer or VNC to remotely control your server, you can also only grab the Spotify Window from the server to your client.
 +
 
 +
To do that, you need to configure sshd on your server and install x11vnc on both server and client as well as tigervnc on the client. Then you can use these scripts to grab either the complete dektop or only the Spotify window, which essentially gets you GUI client-like behavior as with MPD.
 +
 
 +
{{bc|<nowiki>
 +
#!/bin/bash
 +
# vncget.sh
 +
 
 +
if [[ $1 == all ]];then
 +
  ssh -f -t -L 5900:localhost:5900 user@host "x11vnc -q -display :0 -auth .Xauthority"
 +
else
 +
  ssh -f -t -L 5900:localhost:5900 user@host ".bin/vncgetspotify.sh"
 +
fi
 +
 +
for i in {1..4}; do
 +
  sleep 2
 +
  if vncviewer localhost:0; then break; fi
 +
done
 +
</nowiki>}}
 +
 
 +
{{bc|<nowiki>
 +
#!/bin/bash
 +
# vncgetspotify.sh
 +
 
 +
export DISPLAY=:0
 +
 
 +
id=$(wmctrl -lx | awk '/spotify.exe.Wine/ {print $1}')
 +
[[ -z $id ]] && id=$(wmctrl -lx | awk '/spotify.Spotify/ {print $1}')
 +
 
 +
x11vnc -sid $id -display :0 -auth .Xauthority
 +
</nowiki>}}
 +
 
 +
You will need to copy the second script to ~/.bin/vncgetspotify.sh on the server and the first script to any place on your client.
 +
 
 +
Finally, to grab the spotify window, run on the client:
 +
 
 +
$ sh vncget.sh
 +
 
 +
or, for the whole desktop:
 +
 
 +
$ sh vncget.sh all
 +
 
 +
===HiDPI Mode===
 +
As the current Spotify build is not DPI aware, the amount to scale the interface by can be specified using the terminal command:
 +
$ spotify --force-device-scale-factor=X
 +
 
 +
where X is the amount to scale the interface by, e.g 2.
 +
 
 +
This change can be added to the {{ic|spotify.desktop}} file, located in the {{ic|/usr/share/applications}} directory, in order to apply the scaling when launching from the desktop.
 +
 
 +
Example {{ic|spotify.desktop}} file:
 +
[Desktop Entry]
 +
Name=Spotify
 +
GenericName=Music Player
 +
Comment=Spotify streaming music client
 +
Icon=spotify-client
 +
Exec=spotify --force-device-scale-factor=2%U
 +
TryExec=spotify
 +
Terminal=false
 +
Type=Application
 +
Categories=Audio;Music;Player;AudioVideo
 +
MimeType=x-scheme-handler/spotify
 +
 
 +
In alternative, it is possible to create an application launcher override in the {{ic|~/.local/share/applications/}} folder so that once the app gets updated, the setting will be kept.
 +
 
 +
Example {{ic|spotify.desktop}} override:
 +
cp /usr/share/applications/spotify.desktop ~/.local/share/applications/
 +
# edit ~/.local/share/applications/spotify.desktop
 +
# so that the following
 +
# Exec=spotify %U
 +
# becomes this:
 +
Exec=spotify --force-device-scale-factor=2 %U
 +
# or use --force-device-scale-factor=1.0000001
 +
# if you are not on HiDPi screen
 +
 
 +
Please keep in mind you need to relaunch your Desktop Manager once, before these override changes will be effective.
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Using search causes the whole interface to blink and then crash ===
 +
 
 +
Spotify is using an old version of Chromium Embedded Framework and hits a bug causing it to crash repeatedly when trying to use the search.  This can be worked around by using the following command line option:
 +
 
 +
  --force-device-scale-factor=1.0000001
 +
 
 +
=== Blinking images and improper rendering while using Spotify Linux with DWM ===
 +
Start spotify as a floating window.
 +
 
 +
You can add this rule to the rules array in your {{ic|config.h}}:
 +
  { "Spotify",    NULL,      NULL,        2,        True,    -1 },
 +
 
 +
This will tell dwm to start spotify as a floating window associated with the tag "2" no matter what window mode you are in. Recompile and install dwm to apply your new settings.
 +
 
 +
=== Broken search, browsing or radio ===
 +
 
 +
: Spotify [http://community.spotify.com/t5/Help-Desktop-Linux-Mac-and/Bug-Desktop-Linux-0-9-0-133-gd18ed589-Having-mixed-locale-breaks/td-p/418270 bug report] concerning non-english locales
 +
If various tabs like browsing only show a blank screen, the search field doesn't seem to do anything or the radio page is broken (stuck when starting and unsresponsive to input) you might be using a custom locale.
 +
 
 +
Try setting the environment variable {{ic|LC_NUMERIC}} to {{ic|en_US.utf8}} before starting Spotify.
 +
 
 +
=== SpotifyHelper.exe crashes (Windows client) ===
 +
 
 +
If SpotifyHelper.exe crashes when starting Spotify, disable the d3d9 library with {{ic|winecfg}}. Go to the "Libraries" tab, choose "d3d9" and click Add. To disable it, click edit and select the "Disable" option.
 +
 
 +
=== Wrong launcher icon (Windows client) ===
 +
 
 +
If the Spotify icon does not show up correctly in your launcher, add the following line to {{ic|~/.local/share/applications/wine/Programs/Spotify.desktop}}:
 +
 
 +
StartupWMClass=spotify.exe
 +
 
 +
=== Deadlock GUI Thread ===
 +
 
 +
Can occur under tiling window managers, such as Awesome, when double-clicking new song or playlist. Edit the file {{ic|~/.config/spotify/Users/[1-9]*-user/prefs}} to add or change the following:
 +
 
 +
ui.track_notifications_enabled=false
 +
 
 +
Restart Spotify. Note that several causes appear to exist for this problem, and this particular fix only applies to select versions of Spotify client and Awesome, and it may be that additional root causes exist for the Debian and Ubuntu users reporting this issue. Observed with Spotify 0.9.17.1.g9b85d436 and Awesome 3.4.15.
 +
 
 +
{{Note|As of Spotify 1.0.17.75-2, {{ic|1=ui.track_notifications_enabled=false}} seems to be ignored. On the other hand some, users report not experimenting the deadlock anymore as of Awesome 3.5.6. Deadlocks could be caused by scripts called by Awesome, which rely on buggy spotify dbus properties. See [https://github.com/acrisci/playerctl/issues/20].}}
 +
 
 +
'''Note:''' This issue has multiple causes, so keep track of what you change while researching this. Update this section with additional scenarios and fixes.
 +
 
 +
=== Pulseaudio ===
 +
 
 +
See [[PulseAudio/Troubleshooting]] and [https://bbs.archlinux.org/viewtopic.php?pid=1393465#p1393465]
 +
 
 +
=== Album art and images are missing, show up as squares; with
 +
Quit spotify, then open spotify preferences {{ic|~/.config/spotify/prefs}}
 +
 
 +
Change @https to @http:
 +
 
 +
  network.proxy.addr="your-proxy.com:80<strong>@http</strong>"
 +
  network.proxy.mode=2
 +
 
 +
See original form post [http://community.spotify.com/t5/Help-Desktop-Linux-Mac-and/Mac-Windows-0-9-0-128-Apps-can-t-connect-anywhere-behind-proxy/m-p/448704#M52332 here].
 +
 
 +
{{Note|As of 1.0.17 it looks like replacing https with http as suggested above can result in no connectivity at all. If this happens an alternative solution is to set 'no proxy' in the GUI use {{Pkg|proxychains-ng}} to force all TCP connection coming from the app through a proxy. Even with HTTP proxies that reject connections on port 80 (and only work for port 443) this works reliably.}}
 +
 
 +
=== Spotify does not detect other devices on local network ===
 +
 
 +
If a firewall is in place, open ports 57621 for UDP and TCP. If you use a variant of the [[iptables]] [[Simple stateful firewall]], the following should do it:
 +
 
 +
  iptables -A TCP -p tcp --dport 57621 -j ACCEPT -m comment --comment spotify
 +
iptables -A UDP -p udp --dport 57621 -j ACCEPT -m comment --comment spotify
 +
 
 +
It is also possible to restrict the source and destination to the local network.
 +
 
 +
=== Search Bar text is invisible when using a dark theme ===
 +
 
 +
The text in the search bar appears to be hardcoded to be white, making it invisible when using a dark Qt theme. To fix this, you'll need to make an override.
 +
 
 +
First create a css file somewhere your account has permission to read/write from (such as your home folder). Call it whatever you like (eg. '''spotify-override.css''').
 +
 
 +
Open the newly created css file and add the following:
 +
 
 +
QLineEdit { color: #000 }
 +
 
 +
Save the file and exit. Next, you need to add the following to the end of your Spotify launcher (substitute the path with the actual path of your css file):
 +
 
 +
-stylesheet=/home/user/spotify-overide.css
 +
 
 +
So your full launch path should look something like this:
 +
 
 +
/usr/share/spotify/spotify-client/spotify -stylesheet=/home/user/spotify-override.css
 +
 
 +
=== Segmentation fault when playing a local file ===
 +
 
 +
The cause of this problem is a missing dependency. For Pulseaudio users, installing {{aur|ffmpeg-compat-54}} should fix it.
  
 
==See also==
 
==See also==
 +
*[https://github.com/acrisci/playerctl playerctl]: A command-line utility and library for controlling media players
 
*[[SpotCommander]]: A web based remote control for Spotify
 
*[[SpotCommander]]: A web based remote control for Spotify
 
*http://www.spotify.com/int/help/faq/wine/
 
*http://www.spotify.com/int/help/faq/wine/
 
*http://www.spotify.com/int/download/previews/
 
*http://www.spotify.com/int/download/previews/

Latest revision as of 10:52, 21 September 2016

Spotify is a digital music service that gives you access to millions of songs.

This Internet music service allows you to select any song in its database and stream for free. The service was recently introduced to the United States after previously being exclusive to Europe. The Linux client is only officially packaged for Debian and Fedora distributions, but is also available in the AUR: spotifyAUR. Officially, they recommend that Linux users run the windows client under Wine. There are also the occasional voice ads in between songs for users who do not wish to subscribe.

Spotify also offers free users the ability to create playlist which can be shuffled, and set to repeat tracks. Content provided by Spotify comes in explicit versions as well as censored.

Installation

Choose which client you would prefer. The Linux client is receiving good reviews. However, if you are comfortable with wine and its configuration, you might want to choose the windows client. Please note that you do not need to install both. There is also the online player (requires flash) on https://play.spotify.com/.

There are also some alternatives to the official spotify client:

  • Clementine — Amarok 1.4 clone, ported to Qt 4, is able of streaming from Spotify with a premium account after activating (downloading) a plugin in the settings.
http://www.clementine-player.org/ || clementine
  • Mopidy — An alternative plug-in based implementation of Music Player Daemon is able of streaming from Spotify with an extension.
https://github.com/mopidy || mopidy+ mopidy-spotifyAUR or despotify-svnAUR

Linux

spotifyAUR from the AUR will automatically download the software. If you wish to play local files you will need to install ffmpeg0.10 as well.

Windows (Wine)

See Wine.

Obtaining Spotify can be done by registering for an account on their Website, the application does not offer in-app registration. However you can obtain the application prior to registering by using the following URL. [1]

After you have registered and downloaded your copy of the installer you will need to run the application through Wine, depending on your setup you may be able to run the application by right clicking the file. If not terminal will work just fine, as long as you run the below command in the directory of your download.

$ wine Spotify\ Installer.exe

Once the application is successfully installed you may run Spotify by using one of the following commands in terminal, or in the ALT+F2 launcher:

If you use a x86_64 copy of ArchLinux, you will have to run it like this:

$ wine "/home/username/.wine/drive_c/Program Files (x86)/Spotify/spotify.exe"

If you use a x86 copy of ArchLinux, you can use this command just fine:

$ wine ~/.wine/drive_c/Program\ Files/Spotify/spotify.exe

If you have any additional problems, I recommend setting the winecfg to Windows XP or Windows 7 emulation.

Global media hotkeys

Spotify has support for media keys like XF86AudioPlay, but out of the box they only work inside Spotify. We can use for example xbindkeys to catch the global media keypresses, and then forward them to Spotify using one of the methods below. If you use xbindkeys, ensure that Spotify is restarted after installation and key configuration otherwise the key events will not be properly caught.

Linux

MPRIS

The Spotify client implements the MPRIS2 D-Bus interface which allows external control.

Playerctl

The playerctlAUR utility provides a command line tool to send commands to MPRIS clients. The only commands you will likely need to bind globally are play-pause, next and previous

$ playerctl play-pause
$ playerctl next
$ playerctl previous

Playerctl will send the command to the first player it finds, so this method will also work with others players such as vlc. To ignore other players, pass --player=spotify as an argument.

D-Bus

An alternative to the above is to manually use D-Bus, which should be available by default as it is a dependency of systemd.

To play or pause the current song in Spotify:

$ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

In order to bind this and the other commands to the media keys you need to install Xbindkeys and edit your .xbindkeysrc and add the following lines:

# Play/Pause
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
XF86AudioPlay

# Next
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
XF86AudioNext

# Previous
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
XF86AudioPrev

# Stop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
XF86AudioStop

If the above commands do not work, try setting the dbus address:

 USER=`whoami`
 PROCESS=spotify
 PID=`pgrep -o -u $USER $PROCESS`
 ENVIRON=/proc/$PID/environ
 if [ -e $ENVIRON ]
 then
     export `grep -z DBUS_SESSION_BUS_ADDRESS $ENVIRON`
 else
     echo "Unable to set DBUS_SESSION_BUS_ADDRESS."
     exit 1
 fi

xdotool

With the help of xdotool it is possible to send your hotkeys to the application. The following script is an example of how to control Spotify from the outside:

#!/bin/sh

case $1 in
   "play")
       key="XF86AudioPlay"
       ;;
   "next")
       key="XF86AudioNext"
       ;;
   "prev")
       key="XF86AudioPrev"
       ;;
   *)
       echo "Usage: $0 play|next|prev"
       exit 1
        ;;
esac
xdotool key --window $(xdotool search --name "Spotify (Premium |Unlimited |Free )?- Linux Preview"|head -n1) $key
exit 0

Let us call it musickeys.sh. Make the script executable:

$ chmod +x musickeys.sh

By executing ./musickeys.sh play you can now toggle playing a song. Now you can bind this script to any tool that catches keypresses, such as xbindkeys.

Windows

If you prefer the wine-version of Spotify, you can use spotifycmdAUR[broken link: archived in aur-mirror] to send actions to Spotify. Here is a sample setup of xmonad bindings using spotifycmd.

Tips & Tricks

Disable track notifications

Note: It is worth noting that if you have a SpotCommanderAUR Server running alongside Spotify, and you disable track notifications by following the instructions below, the SpotCommander Client running on your mobile device will display that “No Music is Playing” and will fail to display track info such as title, artist, album art, etc. Apart from that, the mobile client still works fine though, and is still able to skip, play, pause, control volume, etc.

After version 0.9.10, track change notifications were enabled by default. They can be quite intrusive. To disable them, add the following line to ~/.config/spotify/Users/<spotifylogin>-user/prefs

 ui.track_notifications_enabled=false

It is also possible to launch spotify with the --ui.track_notifications_enabled=false option.

Show track notifications

playerctlAUR provides a library you can use with python-gobject and a notification daemon such as dunst to show the artist and title in a notification when the track changes.

#!/usr/bin/env python3

from gi.repository import Playerctl, GLib
from subprocess import Popen

player = Playerctl.Player()

def on_track_change(player, e):
    track_info = '{artist} - {title}'.format(artist=player.get_artist(), title=player.get_title())
    Popen(['notify-send', track_info])

player.on('metadata', on_track_change)

GLib.MainLoop().run()

Skip overplayed radio tracks

Another use of the playerctlAUR library is to skip tracks that are played too much on radio when you do not necessarily want to downvote these tracks because you may want to hear them again later on that station.

#!/usr/bin/env python3

from gi.repository import Playerctl, GLib

player = Playerctl.Player()

played_out = ['Zu Fuss', 'Walk And Talk', 'Neuland']

def on_track_change(player, e):
    if player.get_title() in played_out:
        player.next()

player.on('metadata', on_track_change)

GLib.MainLoop().run()

Mute commercials

blockify

With blockify you can mute commercials. It is available in the AUR as blockifyAUR.

To have this start and run in the background every time Spotify starts you will need to automate this yourself:

#!/bin/sh

spotify=/usr/bin/spotify

if [[ -x $spotify && -x /usr/bin/blockify ]];
then
  blockify &
  block_pid=$!
  $spotify
  trap "kill -9 $block_pid" SIGINT SIGTERM EXIT
fi

By placing this script at /usr/local/bin/spotify, it gets preferred to /usr/bin/spotify everytime you start Spotify, so there's nothing else to change and updates won't break it.

spotblock

spotblock (spotblock-gitAUR) is a resource-efficient ad blocker that runs as a systemd daemon.

Spotify-AdKiller

Spotify-AdKiller (spotify-adkillerAUR) is another alternative to block Spotify adds.

Remote Control

Send commands via SSH

If you set up ssh on the server, you can send controls from a client to a remote Spotify instance with

$ ssh user@host yourcommand

where yourcommand can be spotifycmd that you installed on the server, or a dbus script for the linux version, as described above.

Grab the Spotify window via SSH

Aside from grabbing the whole desktop with TeamViewer or VNC to remotely control your server, you can also only grab the Spotify Window from the server to your client.

To do that, you need to configure sshd on your server and install x11vnc on both server and client as well as tigervnc on the client. Then you can use these scripts to grab either the complete dektop or only the Spotify window, which essentially gets you GUI client-like behavior as with MPD.

#!/bin/bash
# vncget.sh

if [[ $1 == all ]];then
  ssh -f -t -L 5900:localhost:5900 user@host "x11vnc -q -display :0 -auth .Xauthority"
else
  ssh -f -t -L 5900:localhost:5900 user@host ".bin/vncgetspotify.sh"
fi
 
for i in {1..4}; do
  sleep 2
  if vncviewer localhost:0; then break; fi
done
#!/bin/bash
# vncgetspotify.sh

export DISPLAY=:0

id=$(wmctrl -lx | awk '/spotify.exe.Wine/ {print $1}')
[[ -z $id ]] && id=$(wmctrl -lx | awk '/spotify.Spotify/ {print $1}')

x11vnc -sid $id -display :0 -auth .Xauthority

You will need to copy the second script to ~/.bin/vncgetspotify.sh on the server and the first script to any place on your client.

Finally, to grab the spotify window, run on the client:

$ sh vncget.sh

or, for the whole desktop:

$ sh vncget.sh all

HiDPI Mode

As the current Spotify build is not DPI aware, the amount to scale the interface by can be specified using the terminal command:

$ spotify --force-device-scale-factor=X

where X is the amount to scale the interface by, e.g 2.

This change can be added to the spotify.desktop file, located in the /usr/share/applications directory, in order to apply the scaling when launching from the desktop.

Example spotify.desktop file:

[Desktop Entry]
Name=Spotify
GenericName=Music Player
Comment=Spotify streaming music client
Icon=spotify-client
Exec=spotify --force-device-scale-factor=2%U
TryExec=spotify
Terminal=false
Type=Application
Categories=Audio;Music;Player;AudioVideo
MimeType=x-scheme-handler/spotify

In alternative, it is possible to create an application launcher override in the ~/.local/share/applications/ folder so that once the app gets updated, the setting will be kept.

Example spotify.desktop override:

cp /usr/share/applications/spotify.desktop ~/.local/share/applications/
# edit ~/.local/share/applications/spotify.desktop
# so that the following
# Exec=spotify %U
# becomes this:
Exec=spotify --force-device-scale-factor=2 %U
# or use --force-device-scale-factor=1.0000001
# if you are not on HiDPi screen

Please keep in mind you need to relaunch your Desktop Manager once, before these override changes will be effective.

Troubleshooting

Using search causes the whole interface to blink and then crash

Spotify is using an old version of Chromium Embedded Framework and hits a bug causing it to crash repeatedly when trying to use the search. This can be worked around by using the following command line option:

 --force-device-scale-factor=1.0000001

Blinking images and improper rendering while using Spotify Linux with DWM

Start spotify as a floating window.

You can add this rule to the rules array in your config.h:

 { "Spotify",     NULL,       NULL,        2,         True,     -1 },

This will tell dwm to start spotify as a floating window associated with the tag "2" no matter what window mode you are in. Recompile and install dwm to apply your new settings.

Broken search, browsing or radio

Spotify bug report concerning non-english locales

If various tabs like browsing only show a blank screen, the search field doesn't seem to do anything or the radio page is broken (stuck when starting and unsresponsive to input) you might be using a custom locale.

Try setting the environment variable LC_NUMERIC to en_US.utf8 before starting Spotify.

SpotifyHelper.exe crashes (Windows client)

If SpotifyHelper.exe crashes when starting Spotify, disable the d3d9 library with winecfg. Go to the "Libraries" tab, choose "d3d9" and click Add. To disable it, click edit and select the "Disable" option.

Wrong launcher icon (Windows client)

If the Spotify icon does not show up correctly in your launcher, add the following line to ~/.local/share/applications/wine/Programs/Spotify.desktop:

StartupWMClass=spotify.exe

Deadlock GUI Thread

Can occur under tiling window managers, such as Awesome, when double-clicking new song or playlist. Edit the file ~/.config/spotify/Users/[1-9]*-user/prefs to add or change the following:

ui.track_notifications_enabled=false

Restart Spotify. Note that several causes appear to exist for this problem, and this particular fix only applies to select versions of Spotify client and Awesome, and it may be that additional root causes exist for the Debian and Ubuntu users reporting this issue. Observed with Spotify 0.9.17.1.g9b85d436 and Awesome 3.4.15.

Note: As of Spotify 1.0.17.75-2, ui.track_notifications_enabled=false seems to be ignored. On the other hand some, users report not experimenting the deadlock anymore as of Awesome 3.5.6. Deadlocks could be caused by scripts called by Awesome, which rely on buggy spotify dbus properties. See [2].

Note: This issue has multiple causes, so keep track of what you change while researching this. Update this section with additional scenarios and fixes.

Pulseaudio

See PulseAudio/Troubleshooting and [3]

=== Album art and images are missing, show up as squares; with Quit spotify, then open spotify preferences ~/.config/spotify/prefs

Change @https to @http:

 network.proxy.addr="your-proxy.com:80@http"
 network.proxy.mode=2

See original form post here.

Note: As of 1.0.17 it looks like replacing https with http as suggested above can result in no connectivity at all. If this happens an alternative solution is to set 'no proxy' in the GUI use proxychains-ng to force all TCP connection coming from the app through a proxy. Even with HTTP proxies that reject connections on port 80 (and only work for port 443) this works reliably.

Spotify does not detect other devices on local network

If a firewall is in place, open ports 57621 for UDP and TCP. If you use a variant of the iptables Simple stateful firewall, the following should do it:

iptables -A TCP -p tcp --dport 57621 -j ACCEPT -m comment --comment spotify
iptables -A UDP -p udp --dport 57621 -j ACCEPT -m comment --comment spotify

It is also possible to restrict the source and destination to the local network.

Search Bar text is invisible when using a dark theme

The text in the search bar appears to be hardcoded to be white, making it invisible when using a dark Qt theme. To fix this, you'll need to make an override.

First create a css file somewhere your account has permission to read/write from (such as your home folder). Call it whatever you like (eg. spotify-override.css).

Open the newly created css file and add the following:

QLineEdit { color: #000 }

Save the file and exit. Next, you need to add the following to the end of your Spotify launcher (substitute the path with the actual path of your css file):

-stylesheet=/home/user/spotify-overide.css

So your full launch path should look something like this:

/usr/share/spotify/spotify-client/spotify -stylesheet=/home/user/spotify-override.css

Segmentation fault when playing a local file

The cause of this problem is a missing dependency. For Pulseaudio users, installing ffmpeg-compat-54AUR should fix it.

See also