Translation(s): English - ?Français - Español - ?Italiano
Spotify is a digital music streaming service that gives you access to millions of songs, podcasts and videos from artists all over the world. There is also an online player and official Linux install instructions. |
Installing Spotify
Debian 8 "Jessie"
Using third-party repositories as recommended below is not supported by the Debian project and could break your system now or when you upgrade later. Use with caution at your own risk!
Add the Spotify repository signing key to be able to verify downloaded packages
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4773BD5E130D1D45
Add the Spotify repository
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
Update list of available packages
sudo apt update
Install Spotify
sudo apt install spotify-client
Debian 9 "Stretch"
Using third-party repositories as recommended below is not supported by the Debian project and could break your system now or when you upgrade later. Use with caution at your own risk!
NB: You will need to install dirmngr if not already installed
sudo apt install dirmngr
dirmngr is installed in Buster
Add the Spotify repository signing key to be able to verify downloaded packages
curl -sS https://download.spotify.com/debian/pubkey_0D811D58.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/repository-spotify-com-keyring.gpg >/dev/null
Add the Spotify repository
echo deb [signed-by=/usr/share/keyrings/repository-spotify-com-keyring.gpg] http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
Update list of available packages
sudo apt update
Install Spotify
sudo apt install spotify-client
Debian 12 "Bookworm" (stable)
Using third-party repositories as recommended below is not supported by the Debian project and could break your system now or when you upgrade later. Use with caution at your own risk!
Add the Spotify repository
$ echo 'deb [signed-by=/etc/apt/keyrings/spotify.gpg] https://repository.spotify.com stable non-free' | sudo tee /etc/apt/sources.list.d/spotify.list
Add the Spotify repository signing key to be able to verify downloaded packages
$ curl -fsSL https://download.spotify.com/debian/pubkey_C85668DF69375001.gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/spotify.gpg > /dev/null
Update list of available packages
# apt update
Install Spotify
# apt install spotify-client
Tricks
Controlling playback using MPRIS D-Bus interface
On minimal systems it might be required to launch the desktop environment or window manager through dbus-launch --exit-with-session (provided by dbus-x11).
Typically you would edit .xinitrc from
exec openbox-session
to
exec dbus-launch --exit-with-session openbox-session
Spotify implements MPRIS interface so commands like these should work:
playerctl --player spotify play-pause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
AppArmor
Here is an working example to lower spotify's access rights.
# cat /etc/apparmor.d/usr.share.spotify.spotify # Last Modified: Sat May 11 00:58:27 2024 include <tunables/global> /usr/share/spotify/spotify flags=(attach_disconnected) { include <abstractions/audio> include <abstractions/dbus-session> include <abstractions/dbus> include <abstractions/dconf> include <abstractions/ibus> include <abstractions/kde> include <abstractions/nameservice> ptrace trace peer=@{profile_name}, unix (receive, send, connect) peer=(addr=@/tmp/.ICE-unix/*), deny /run/udev/data/** r, # you can see that it doesn't allow access to our private data # by going into settings->your library->show local files->add source # # if you want to allow access you can add something like this # # owner @{HOME}/music/ r, # the /** should be enough # owner @{HOME}/music/** r, # /etc/udev/udev.conf r, /etc/xdg/Trolltech.conf rk, # this could be improved /lib/** mr, /sys/bus/pci/devices/ r, /sys/devices/pci[0-9]*/**/block/**/size r, /sys/devices/pci[0-9]*/**/class r, /sys/devices/pci[0-9]*/**/device r, /sys/devices/pci[0-9]*/**/irq r, /sys/devices/pci[0-9]*/**/removable r, /sys/devices/pci[0-9]*/**/resource r, /sys/devices/pci[0-9]*/**/uevent r, /sys/devices/pci[0-9]*/**/vendor r, /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq r, /sys/devices/virtual/block/**/removable r, /sys/devices/virtual/block/**/size r, /sys/devices/virtual/block/**/uevent r, # this could be improved /usr/** mr, /usr/bin/xdg-open rUx, /usr/share/spotify/** mr, /usr/share/spotify/spotify rix, @{PROC}/ r, @{PROC}/sys/kernel/shmmax r, owner /run/user/*/dconf/ w, owner /run/user/*/dconf/user rw, owner /{dev,run}/shm/{,.}org.chromium.* mrw, owner @{HOME}/.cache/spotify/ rw, owner @{HOME}/.cache/spotify/** rwk, owner @{HOME}/.config/gtk-2.0/gtkfilechooser.ini r, owner @{HOME}/.config/spotify/ rw, owner @{HOME}/.config/spotify/** rwk, owner @{HOME}/.gtkrc-2.0 r, owner @{HOME}/.gtkrc-2.0-gnome-color-chooser r, owner @{HOME}/.local/share/fonts/ r, owner @{HOME}/.local/share/fonts/** r, owner @{HOME}/.local/share/spotify/ rw, owner @{HOME}/.local/share/spotify/** rwk, # owner @{HOME}/.mozilla/plugins/ r, # owner @{HOME}/.mozilla/plugins/** r, # o_0... maybe we don't need that? owner @{HOME}/.pki/nssdb/* rwk, # owner @{PROC}/[0-9]*/auxv r, # owner @{PROC}/[0-9]*/cmdline r, # owner @{PROC}/[0-9]*/fd/ r, # owner @{PROC}/[0-9]*/io r, # owner @{PROC}/[0-9]*/oom_{,score_}adj w, # owner @{PROC}/[0-9]*/smaps r, # owner @{PROC}/[0-9]*/stat r, # owner @{PROC}/[0-9]*/statm r, # owner @{PROC}/[0-9]*/status r, # owner @{PROC}/[0-9]*/task/ r, # owner @{PROC}/[0-9]*/task/[0-9]*/stat r, }