Define systemd service for spotifyd
This commit is contained in:
parent
7a9a2a7ef2
commit
d81e6d4063
|
@ -1,24 +1,37 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let unstable = import <nixpkgs-unstable> {};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
|
# services.spotifyd doesn't work so we'll have to roll our own spotifyd +
|
||||||
|
# spotify-tui solution. I can't get the dbus interface doesn't work, though,
|
||||||
|
# so we have to wait for spotify-tui to implement CLI command for controlling
|
||||||
|
# spotify playback (see https://github.com/Rigellute/spotify-tui/issues/147)
|
||||||
|
# or for spotifyd to get fixed.
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
# services.spotifyd doesn't work so...
|
unstable.spotifyd
|
||||||
spotifyd
|
|
||||||
(writeScriptBin "spt" ''
|
(writeScriptBin "spt" ''
|
||||||
#!${stdenv.shell}
|
#!${stdenv.shell}
|
||||||
if ! pgrep -x spotifyd >/dev/null; then
|
if ! systemctl --user is-active spotifyd >/dev/null; then
|
||||||
spotifyd --backend pulseaudio \
|
systemctl --user start spotifyd
|
||||||
--cache_path "$HOME/.cache/spotifyd" \
|
|
||||||
--username accounts@v0.io \
|
|
||||||
--password $(pass www/spotify.com)
|
|
||||||
fi
|
fi
|
||||||
${unstable.spotify-tui}/bin/spt
|
${unstable.spotify-tui}/bin/spt
|
||||||
'')
|
'')
|
||||||
|
|
||||||
# spotify-tui is fine for selecting and playing music, but incomplete. We
|
# spotify-tui is fine for selecting and playing music, but incomplete. We
|
||||||
# occasionally still need the official client.
|
# occasionally still need the official client for more sophisticated search
|
||||||
|
# and the "made for you" playlists.
|
||||||
spotify
|
spotify
|
||||||
];
|
];
|
||||||
|
|
||||||
|
systemd.user.services.spotifyd.serviceConfig =
|
||||||
|
let spotifydConf = pkgs.writeText "spotifyd.conf" ''
|
||||||
|
[global]
|
||||||
|
username = accounts@v0.io
|
||||||
|
password_cmd = ${pkgs.pass}/bin/pass www/spotify.com | head -n1
|
||||||
|
backend = pulseaudio
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
ExecStart = "${pkgs.unstable.spotifyd}/bin/spotifyd --no-daemon --cache-path /tmp/spotifyd --config-path ${spotifydConf}";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = 6;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue