Use onevent parameter to enhance the sound quality for spotifyd. Automatically start and stop mpd (and other service etc) when play and stop Spotify Connect.
root@runeaudio(rw):~# spotifyd --help
Usage: spotifyd [options]
Options:
-c, --config CONFIG Path to a config file.
-u, --username USERNAME
Spotify user name.
-p, --password PASSWORD
Spotify password.
--device DEVICE Audio device, given by aplay -L.
--mixer DEVICE Audio mixer
--bitrate DEVICE
Any of 96, 160, and 320.
--pid PID-FILE Path to PID file.
--device_name DEVICE
Name of this Spotify device.
--backend BACKEND
Audio backend.
--cache_path PATH
Path to cache location.
--volume-normalisation
Apply volume normalisation per track.
--normalisation-pregain PREGAIN
dB of pregain for volume normalisation
--onevent COMMAND
Run a command on events. Environment variables
PLAYER_EVENT, TRACK_ID,OLD_TRACK_ID are passed to the
command.
--volume-control CONTROLLER
Possible values are alsa, alsa_linear, and softvol.
-v, --verbose Add debug information to log.
--no-daemon Don't detach from console.
--backends List available audio backends.
-h, --help Print this help text.
Create spotifyd_even.sh. Set chmod 755:
nano /home/root/spotifyd_event.sh
#!/bin/bash
case "$PLAYER_EVENT" in
start)
# Stop mpd
systemctl stop mpd
exit
;;
stop)
# Start mpd
systemctl start mpd
exit
;;
esac
exit 0
Edit spotifyd.service:
ExecStart=/usr/bin/spotifyd --no-daemon --onevent /home/root/spotifyd_event.sh
Done!!!
PS: We may need to restart the related scripts to re-set the service settings.