Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Raspberry install docs. #1243

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
123 changes: 123 additions & 0 deletions docs/src/installation/Raspberry-Pi-32.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Raspberry Pi install guide

This guide will help you to install `spotifyd` on a Raspberry Pi and have it always running.

## Download

1. Download the latest ARMv6 from <https://github.com/Spotifyd/spotifyd/releases> (use `wget`)
2. Unzip the file: `tar xzf spotifyd-linux-arm6*`
You will now see a file called `spotifyd`. You can run it with `./spotifyd --no-daemon`
The binaries on the download site are all 32 bit binaries, you cannot easily run them on a current 64-bit Raspberry Pi OS.
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved
Trying to run them will result in 'cannot execute: required file not found'
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved
To run on a 64 bit Raspberry Pi OS, see `Raspberry-Pi-64.md`.
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

It is recommended to copy the file to usr/bin, so that everyone can run it or use it for a daemon:
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

```bash
sudo cp ./spotifyd /usr/bin
```

## Systemd daemon file

Create a systemd service file and copy the [default configuration](https://github.com/Spotifyd/spotifyd/blob/master/contrib/spotifyd.service) into it. Change **ExecStart** to where you unzipped the `spotifyd` binary.

```bash
sudo nano /etc/systemd/system/spotifyd.service
```

If you want to run as user instead of root or have some `Failed to get D-Bus connection: Connection refused`, you define `spotifyd.service` in your home directory:

```bash
mkdir -p ~/.config/systemd/user/
nano ~/.config/systemd/user/spotifyd.service
systemctl --user daemon-reload
```

Or in the user diretcory of systemd:

```bash
sudo nano /etc/systemd/user/spotifyd.service
```
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

## Configuring spotifyd

Spotifyd comes pre-configured with defaults that should be working in most cases, but if you want to tweak it further to your needs, have a look at File.md at the [configuration section](../config/) of this book.
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

## Start the service

As user daemon

```bash
systemctl --user start spotifyd.service
```

As system daemon

```bash
sudo systemctl start spotifyd.service
```

Now see if you can find it in the normal Spotify client (Devices in right bottom corner). Retry the above steps if you can't find it.
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

## Starting spotifyd at boot

As system daemon:

```bash
sudo systemctl enable spotifyd.service
```

As user daemon is not recommended, it crashes currently with Message: called 'Result::unwrap()' on an 'Err' value: DnsSdError(Os { code: 19, kind: Uncategorized, message: "No such device" }):

```bash
sudo loginctl enable-linger <username>
systemctl --user enable spotifyd.service
```

The first command is required to enable your user to run long-running services. Without it `systemd` would kill the `spotifyd` process as soon as you log out, and only run it when you log in.
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

Now `spotifyd` is always running on the Pi, so you can use it as a listening device remotely!

## Starting with dbus enabled at boot
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

If you have dbus enabled, you need to to configure spotifyd to use the system dbus as it can't register services on the session dbus at boot.
You need to have a config file and configure to use the system dbus, see `Configuring spotifyd`, you can delete everything you don't need to use the standard values. But you need to configure 2 values:

```config
use_mpris = true
dbus_type = "system"
```

In the standard DBus config, no one is allowed to register services on the system dbus, so you need to configure it. Create a configuration file under /usr/share/dbus-1/system.d/, eg. spotifyd-dbus.conf (must end with .conf)
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

```bash
sudo nano /usr/share/dbus-1/system.d/spotifyd-dbus.conf
```

Add the following content:

```content
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
<policy user="root">
<allow own_prefix="org.mpris.MediaPlayer2.spotifyd"/>
<allow send_type="method_call" log="true"/>
</policy>
<policy context="default">
</policy>
</busconfig>
```

If you try to run as user, replace root with the user account name.

## Known issues / Logging
Logging in files is currently not possible for the daemon setup, the daemon crashes without the --no-daemon argument (redirects the output to stdout).
Without the parameter it tries to output at syslog, but even with syslog installed it crashed.
To get at least the latest output run

Drexel2k marked this conversation as resolved.
Show resolved Hide resolved
```bash
sudo systemctl status spotifyd.service
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could remove this part before we merge, since this is probably not accurate.

Copy link
Author

@Drexel2k Drexel2k Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I took this and the whole discussion as an opportunity to overwork the docs again. Most of the topics were general Linux topics, so I separated the system/sistribution specific topics and the general Linux topics. General topics are now in 'Build-on-Linux.md' and 'Run-on-Linux.md', the specific files like Raspberry files are now just a small entry point with few specific topics and links to the general files. At least the run file can also be linked in the Fedora file and maybe also in the FreeBSD file I think.

From the known issues I removed the logging issue, but added the DnsSdError and new issue: I switch to the PulseAudio backend because I have short overlaps of Spotify and radio playback on my app, which caused it to crash, because my HifiBerry amp isn't capable of mixing 2 audio streams in hardware. But as a system wide service, I get a connection refused error when accessing the PulseAudio backend, first I thought I cannot access a service run as user (which PulseAudio is) from a process run as root, but I configured the system service to run with my normal user and the problem persists. I found here: #685 that it may be an issue with RuntimeDirectory of system services, but I didn't had the time yet to investigate it further. If you know this and have a solution, you can remove the issue and maybe tell me the solution. ;) Otherwise I try to find a solution next year.

And I also tried to unified some wordings like the use of compile/build and daemon/service.

So far, have a nice christmas and holiday season!

Copy link
Author

@Drexel2k Drexel2k Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I can also help updating instructions on the homepage, just let me know how.
Or if I shall build ARM64 binaries for the download page I can also do it.

84 changes: 84 additions & 0 deletions docs/src/installation/Raspberry-Pi-64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 64 bit Raspery OS build guide

To run spotifyd on a 64 bit Raspberry Pi OS, you have two possiblities. Compile the 64 bit binary by yourself or add the 32 bit architecture as
an additional architecture to your 64 bit Raspberry Pi OS.

Let's start with compiling the 64 bit version, as it offers you more possibilities like adding the DBus feature for controlling the service with
DBus commands.

## Option 1: Compiling the 64 bit version
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved

### Uninstall the preinstalled rust compiler

spotifyd may require a newer rust toolchain than the one which is delivered with Raspberry Pi OS.

```bash
sudo apt remove rustc
```

### Install the rust toolchain

To install the latest rust toolchain, follow the installation instructions on [rustup.rs][rustup].

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

Chose simply option 1.

After installation finished, enter

```bash
source "$HOME/.cargo/env"
```

### Clone the repository

E.g. in your Downloads Directory. If it does not exist, create it or do it somewhere else.

```bash
cd /home/user/Downloads
git clone https://github.com/Spotifyd/spotifyd.git
```

### Building spotifyd

This takes a while...

```bash
cd spotifyd
cargo build --release
```

This will build a basic version, but you can add additional features like the mentioned DBus or other sound backends by adding additional flags.

E.g. with DBus support

```bash
cd spotifyd
cargo build --release --features dbus_mpris
```

The resulting binary will be placed in `./target/release/spotifyd` and you can run it using `./target/release/spotifyd`.
Now you can go on with the instructions in `Raspberry-Pi-32.md`, the other instructions are the same once you have the binary running.

## Option 2: Add the 32 bit architecture

### Adding architecture and dependency packages

These commands add the architecture and install the required packages for the architecure:

```bash
dpkg --add-architecture armhf
sudo apt update
sudo apt install libasound2-plugins:armhf
```

Now you can go on with the instructions in `Raspberry-Pi-32.md`, but download the `armhf-slim.tar.gz` file instead of the armv6 file.
Drexel2k marked this conversation as resolved.
Show resolved Hide resolved
The other instructions are the same once you have the binary running.
Downloading other variants like full or default may require further armhf packages to be installed with the command like above:

```bash
sudo apt install packagename:armhf
```

47 changes: 0 additions & 47 deletions docs/src/installation/Raspberry-Pi.md

This file was deleted.