From 048429f5931ae395da15b5860b7f129ba6771027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Wed, 28 Oct 2020 20:29:01 +0100 Subject: [PATCH] feat: split spotify config into spotifyd --- configs/packages/default.nix | 4 ++++ configs/{spotify.nix => spotifyd.nix} | 16 +++------------- 2 files changed, 7 insertions(+), 13 deletions(-) rename configs/{spotify.nix => spotifyd.nix} (51%) diff --git a/configs/packages/default.nix b/configs/packages/default.nix index 62a020c..2af9a00 100644 --- a/configs/packages/default.nix +++ b/configs/packages/default.nix @@ -136,6 +136,10 @@ par qrencode wtf + + spotify + spotify-tui + playerctl ]; } diff --git a/configs/spotify.nix b/configs/spotifyd.nix similarity index 51% rename from configs/spotify.nix rename to configs/spotifyd.nix index 2a8d0cd..83644f9 100644 --- a/configs/spotify.nix +++ b/configs/spotifyd.nix @@ -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 ; password = fileContents ; 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 = {