Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] Spotifyd issues with Runit (Read 2297 times) previous topic - next topic
0 Members and 3 Guests are viewing this topic.

[SOLVED] Spotifyd issues with Runit

I've been having a lot of trouble getting spotifyd to run as a daemon and also connect to my pulseaudio instance. I don't understand why spotifyd isn't getting connected to pulseaudio whenever I use it or why it's not working. Should I be using pulseaudio as a system daemon? Maybe use JACK since I need it in a few cases anyway?

What I don't understand is why I can run spotifyd in tty2 while I'm in tty7, but it doesn't work as a system service.

Here's what I've got.
runsv spotifyd:
Code: [Select]
#!/bin/sh

export PATH=$PATH:$HOME/.cargo/bin
export DISPLAY=':0'

# TODO check to see if pulseaudio or JACK is running
sudo sv check dbus >/dev/null || exit 1
exec spotifyd -b pulseaudio --no-daemon

runsv user (which runs spotifyd as my user):
Code: [Select]
#!/bin/sh

loginctl list-users | grep -i user || exit 1
exec 2>&1 \
sudo -H -u user  runsvdir -P /home/user/service/ 'log:...'

and then my dwm config, which runs when I log into sddm:
Code: [Select]
#!/bin/sh

feh --bg-scale ~/wallpaper.jpg

# Allows for alpha channel background
# Turn this off if a GUI app doesn't work right
picom -b
exec flameshot &
pulseaudio --start -D
exec thunderbird &
exec discord &
exec brave &

# TODO Jack audio
exec pavucontrol &

# Keyboard repeat rate
xset r rate 280 40

while :
do

xsetroot -name " `date +'%B %d, %Y | %A %I:%M %p'` "
sleep 5s

done &

Re: Spotifyd issues with Runit

Reply #1
I thought it was something stupid with my installation but it just got initialized before pulseaudio was spawned (and I turned off autospawn so I can regulate it with runit)

Re: [SOLVED] Spotifyd issues with Runit

Reply #2
Hi Galestrike,
I see you managed to bypass spotifyd's systemd dependency, and, like me are using runit. How exactly do you achieve this? I see you are using two scripts, that are somehow used with runsv and runsvdir commands, but these take directories, not bash scripts. Could you elaborate on this so i could copy this solution on my machine?

Re: [SOLVED] Spotifyd issues with Runit

Reply #3
i am sure, that @linuxer  will soon prepare for your a package in universe! ;)


Re: [SOLVED] Spotifyd issues with Runit

Reply #5
[UPDATE] spotifyd and spotifyd services have been added to universe repo.

If not done yet, add the following lines at your /etc/pacman.conf

Code: [Select]
[universe]

Server = https://universe.artixlinux.org/$arch

Have fun

Re: [SOLVED] Spotifyd issues with Runit

Reply #6
Allright. First. Many thanks for this. Second... so I am using spotify-qt as a client, but there is no sound when playing back any of my songs. Do I have to install pulseaudio or will alsa sufice, but needs some tweaking? This is my config for spotifyd:
Code: [Select]
[global]
# Your Spotify account name.
username = XXX

# Your Spotify account password.
password = YYY

# 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.
#
# This is an alternative to the `password` field. Both
# can't be used simultaneously.
#use_keyring = true

#
# If set to true, `spotifyd` tries to bind to the session dbus
# and expose MPRIS controls. When running headless, without a dbus session,
# then set this to false toavoid binding errors
#
use_mpris = true

# The audio backend used to play the your music. To get
# a list of possible backends, run `spotifyd --help`.
backend = "alsa"

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

# The alsa control device. By default this is the same
# name as the `device` field.
control = "alsa"  # omit for macOS

# The alsa mixer used by `spotifyd`.
mixer = "alsamixer"

# 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 = "device_name_in_spotify_connect"

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

# 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"

# 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

# 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, tv,
# avr (Audio/Video Receiver), stb (Set-Top Box), and audiodongle.
device_type = "speaker"

also, Im not sure which device should be in variable 'device', since the command apla -L does not show 'alsa':

Code: [Select]
null
    Discard all samples (playback) or generate zero samples (capture)
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pipewire
    PipeWire Sound Server
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
default:CARD=SB
    HDA ATI SB, ALC887-VD Analog
    Default Audio Device
sysdefault:CARD=SB
    HDA ATI SB, ALC887-VD Analog
    Default Audio Device
front:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    Front output / input
surround21:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=SB,DEV=0
    HDA ATI SB, ALC887-VD Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
usbstream:CARD=SB
    HDA ATI SB
    USB Stream Output
hdmi:CARD=NVidia,DEV=0
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
    HDA NVidia, HDMI 1
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
    HDA NVidia, HDMI 2
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
    HDA NVidia, HDMI 3
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=4
    HDA NVidia, HDMI 4
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=5
    HDA NVidia, HDMI 5
    HDMI Audio Output
usbstream:CARD=NVidia
    HDA NVidia
    USB Stream Output

 

Re: [SOLVED] Spotifyd issues with Runit

Reply #7
Well, my self is not a spotify user, but as mentioned here, spotify needs pulseaudio

Re: [SOLVED] Spotifyd issues with Runit

Reply #8
So the docu in the config file is somewhat missleading. Thanks linuxer.

Re: [SOLVED] Spotifyd issues with Runit

Reply #9
Well, my self is not a spotify user, but as mentioned here, spotify needs pulseaudio
I was having issues with spotifyd and spotify-tui. Turns out all I needed to do was delete the spotifyd config file, then rewrite it to only include username, password, and backend = "pulseaudio"

Thanks!