1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat: split spotify config into spotifyd

This commit is contained in:
2020-10-28 20:29:01 +01:00
parent 59cacae72e
commit 048429f593
2 changed files with 7 additions and 13 deletions

View File

@@ -136,6 +136,10 @@
par
qrencode
wtf
spotify
spotify-tui
playerctl
];
}

View File

@@ -2,11 +2,11 @@
let
inherit (lib.strings) fileContents;
in {
environment.systemPackages = with pkgs; [ spotify spotify-tui playerctl ];
services.dbus.packages = [ pkgs.gnome3.dconf ];
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/audio/spotifyd.nix
systemd.user.services.spotifyd = let
spotifyd = pkgs.unstable.spotifyd.override {
spotifyd = pkgs.spotifyd.override {
withMpris = true;
withPulseAudio = true;
inherit (pkgs) libpulseaudio dbus;
@@ -16,20 +16,10 @@ in {
username = fileContents <secrets/spotify/username>;
password = fileContents <secrets/spotify/password>;
backend = "pulseaudio";
on_song_change_hook = toString (pkgs.writers.writeDash "songinfo" ''
PATH=$PATH:${
lib.makeBinPath [ pkgs.playerctl pkgs.gawk pkgs.libnotify ]
}
metadata=$(playerctl metadata --player spotifyd)
title=$(echo "$metadata" | awk '/^xesam:title\s/ { print substr($0, index($0, $3)) }')
artist=$(echo "$metadata" | awk '/^xesam:artist\s/ { print substr($0, index($0, $3)) }' | paste --serial --delimiters "/")
album=$(echo "$metadata" | awk '/^xesam:album\s/ { print substr($0, index($0, $3)) }')
notify-send --app-name=" Spotify" "$title" "$artist $album"
'');
};
});
in {
wantedBy = [ "multi-user.target" ];
wantedBy = [ "default.target" ];
after = [ "network-online.target" "sound.target" ];
description = "spotifyd, a Spotify playing daemon";
serviceConfig = {