Spotifyd/spotifyd

Won't start as a Service on Arch, launches "fine" manually

KhinaraJade opened this issue · 3 comments

Description
After tinkering for about 4h now to get this working, it seems i have a major Problem.
When i try to launch it as a systemwide service, it stops with "code=exited, status=101"
When i launch it direct via "spotifyd --no-daemon --config-path "/etc/spotifyd.conf" it launches but stays hidden from spotify-tui.

To Reproduce
Steps to reproduce the behavior:

  1. launch it as a service
  2. check with "systemctl status spotifyd"
  3. See error as mentioned above

Expected behavior
service is running and shown on spotify-tui

Logs

Click to show logs
● spotifyd.service - A spotify playing daemon
Loaded: loaded (/etc/systemd/system/spotifyd.service; enabled; preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2023-10-23 00:14:29 CEST; 6s ago
Docs: https://github.com/Spotifyd/spotifyd
Process: 5855 ExecStart=/usr/bin/spotifyd --no-daemon --config-path /etc/spotifyd.conf (code=exited, stat>
Main PID: 5855 (code=exited, status=101)
CPU: 17ms
  

Compilation flags

  • dbus_mpris
  • dbus_keyring
  • alsa_backend
  • portaudio_backend
  • pulseaudio_backend
  • rodio_backend

Versions (please complete the following information):

  • OS: Garuda Linux with 6.5.8-zen1-1 Kernel
  • Spotifyd: 0.3.5

When launching manually, it throws no errors at all. It's just hidden from spotify-tui.

Startuplog when launched via terminal

Click to show logs
╰─λ spotifyd --no-daemon --config-path "/etc/spotifyd.conf"
Loading config from "/etc/spotifyd.conf"
No proxy specified
Using alsa volume controller.
Keyring is ignored, since you already configured a password
Ignoring blacklisted access point ap-gew4.spotify.com:4070
Ignoring blacklisted access point ap-gew4.spotify.com:443
Ignoring blacklisted access point ap-gew4.spotify.com:80
Connecting to AP "ap-gew1.spotify.com:443"
Authenticated as "MyUserName" !
Country: "DE"
Converting with ditherer: tpdf
Using PulseAudioSink with format: S16
Couldn't fetch metadata from spotify: Nothing playing at the moment.

  
Click to show Config (org. Username and Password removed)
[global]
# Your Spotify account name.
username = "MyUserName"

# Your Spotify account password.
password = "MyPassword"

# A command that gets executed and can be used to
# retrieve your password.
# The command should return the password on stdout.
#
# This is an alternative to the `password` field. Both
# can't be used simultaneously.
password_cmd = "command_that_writes_password_to_stdout"

# If set to true, `spotifyd` tries to look up your
# password in the system's password storage.
#
# Note, that the `password` field will take precedence, if set.
use_keyring = true

# If set to true, `spotifyd` tries to bind to dbus (default is the session bus)
# and expose MPRIS controls. When running headless, without the session bus,
# you should set this to false, to avoid errors. If you still want to use MPRIS,
# have a look at the `dbus_type` option.
use_mpris = true

# The bus to bind to with the MPRIS interface.
# Possible values: "session", "system"
# The system bus can be used if no graphical session is available
# (e.g. on headless systems) but you still want to be able to use MPRIS.
# NOTE: You might need to add appropriate policies to allow spotifyd to
# own the name.
dbus_type = "session"

# The audio backend used to play music. To get
# a list of possible backends, run `spotifyd --help`.
backend = "pulseaudio" # use portaudio for macOS [homebrew]

# The alsa audio device to stream audio. To get a
# list of valid devices, run `aplay -L`,
# device = "alsa_output.usb-Astro_Gaming_Astro_A50-00.stereo-game"  # omit for macOS

# The PCM sample format to use. Possible values
# are F32, S32, S24, S24_3, S16.
# Change this value if you encounter errors like
# "Alsa error PCM open ALSA function 'snd_pcm_hw_params_set_format' failed with error 'EINVAL: Invalid argument'"
audio_format = "S16"

# The alsa control device. By default this is the same
# name as the `device` field.
# control = "alsa_output.usb-Astro_Gaming_Astro_A50-00.stereo-game"  # omit for macOS

# The alsa mixer used by `spotifyd`.
# mixer = "PCM"  # omit for macOS

# The volume controller. Each one behaves different to
# volume increases. For possible values, run
# `spotifyd --help`.
volume_controller = "alsa"  # use softvol for macOS

# A command that gets executed in your shell after each song changes.
# on_song_change_hook = "command_to_run_on_playback_events"

# The name that gets displayed under the connect tab on
# official clients. Spaces are not allowed!
device_name = "Gamingstation"

# The audio bitrate. 96, 160 or 320 kbit/s
bitrate = 320

# The directory used to cache audio data. This setting can save
# a lot of bandwidth when activated, as it will avoid re-downloading
# audio files when replaying them.
#
# Note: The file path does not get expanded. Environment variables and
# shell placeholders like $HOME or ~ don't work!
cache_path = "cache_directory"

# The maximal size of the cache directory in bytes
# The example value corresponds to ~ 1GB
max_cache_size = 1000000000

# If set to true, audio data does NOT get cached.
no_audio_cache = true

# Volume on startup between 0 and 100
# NOTE: This variable's type will change in v0.4, to a number (instead of string)
initial_volume = "90"

# If set to true, enables volume normalisation between songs.
volume_normalisation = true

# The normalisation pregain that is applied for each song.
normalisation_pregain = -10

# After the music playback has ended, start playing similar songs based on the previous tracks.
autoplay = true

# The port `spotifyd` uses to announce its service over the network.
# zeroconf_port = 1234

# The proxy `spotifyd` will use to connect to spotify.
# proxy = "http://proxy.example.org:8080"

# The displayed device type in Spotify clients.
# Can be unknown, computer, tablet, smartphone, speaker, t_v,
# a_v_r (Audio/Video Receiver), s_t_b (Set-Top Box), and audio_dongle.
device_type = "computer"

  

I tried different approaches with the config, but nothing seems to fix the issue i'm facing right now....
tried with alsa, tried with pulseaudio and devices etc... nothing helped.

EDIT: removed the service from systemd and now it runs perfect when launched manually via terminal. But running it as a service would be the goal.

j4nk00 commented

The issue is that systemd doesn't have access to audio group.
Try to add in spotifyd.service below [Service]

[Service]
User=root
Group=audio

This workarund works for me on Lxc Debian.

eladyn commented

Sorry for not responding for so long. Running spotifyd as a system service is a bit more advanced and in most contexts, you should be fine running spotifyd as a systemd user service, which is also what is described in the docs.

If you still want to go for the system service variant, you need to disable use_mpris in your config, since that won't work without further tinkering. Generally, you should comment all the options in the configuration file that you don't actively need to change to avoid confusions.

Since your systemd output doesn't really give any clue, could you post your output of journalctl -eu spotifyd.service?

Hey eladyn. Even on my end this happens.
I've checked the logs and everything that is able to produce something i could work with. My fix was simply commented out
# dbus_type = "session"

and then it works fine. It wasn't just able to connect to the dbus....