From 9a33c1a106250591e247baf831e12515916ee0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Wed, 20 May 2020 20:45:00 +0200 Subject: [PATCH] chore: update, spotify, notify --- .versions/nixpkgs-unstable.json | 6 +++--- .versions/nixpkgs.json | 6 +++--- configs/i3.nix | 2 +- configs/spotify.nix | 33 +++++++++++++++++++++++++++++---- dot/i3status-rust.nix | 10 +++++----- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.versions/nixpkgs-unstable.json b/.versions/nixpkgs-unstable.json index e6382a0..a79da4a 100644 --- a/.versions/nixpkgs-unstable.json +++ b/.versions/nixpkgs-unstable.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels.git", - "rev": "22a3bf9fb9edad917fb6cd1066d58b5e426ee975", - "date": "2020-04-21T08:56:52+02:00", - "sha256": "089hqg2r2ar5piw9q5z3iv0qbmfjc4rl5wkx9z16aqnlras72zsa", + "rev": "0f5ce2fac0c726036ca69a5524c59a49e2973dd4", + "date": "2020-05-19T01:31:20+02:00", + "sha256": "0nkk492aa7pr0d30vv1aw192wc16wpa1j02925pldc09s9m9i0r3", "fetchSubmodules": false } diff --git a/.versions/nixpkgs.json b/.versions/nixpkgs.json index c0ba745..b2c0aa9 100644 --- a/.versions/nixpkgs.json +++ b/.versions/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels.git", - "rev": "1e90c46c2d98f9391df79954a74d14f263cad729", - "date": "2020-04-20T23:47:17-04:00", - "sha256": "1xs0lgh3q1hbrj0lbpy3czw41cv6vxx9kdf2npwc58z8xq3sdqmh", + "rev": "82b5f87fcc710a99c47c5ffe441589807a8202af", + "date": "2020-05-19T09:19:41+02:00", + "sha256": "0wz07gzapdj95h9gf0rdc2ywgd7fnaivnf4vhwyh5gx24dblg7q8", "fetchSubmodules": false } diff --git a/configs/i3.nix b/configs/i3.nix index 064e4b5..8ab466f 100644 --- a/configs/i3.nix +++ b/configs/i3.nix @@ -27,7 +27,7 @@ let if [ -n "$1" ]; then xdotool key Shift+Insert else - notify-send "'$chosen' copied to clipboard." & + notify-send --app-name="emoji-menu" "'$chosen' copied to clipboard." & fi ''; diff --git a/configs/spotify.nix b/configs/spotify.nix index 5ef488e..860d888 100644 --- a/configs/spotify.nix +++ b/configs/spotify.nix @@ -7,15 +7,40 @@ in environment.systemPackages = with pkgs; [ spotify spotify-tui + playerctl ]; - services.spotifyd = { - enable = true; - config = toTOML { + # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/audio/spotifyd.nix + systemd.user.services.spotifyd = + let + spotifyd = pkgs.unstable.spotifyd.override { + withMpris = true; + withPulseAudio = true; + inherit (pkgs) libpulseaudio dbus; + }; + spotifydConf = pkgs.writeText "spotifyd.conf" (lib.generators.toINI {} { global = { username = fileContents ; - password_cmd = "${pkgs.pass}/bin/pass shared/spotify/password"; + 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" "$album — $artist" + ''); }; + }); + in { + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" "sound.target" ]; + description = "spotifyd, a Spotify playing daemon"; + serviceConfig = { + ExecStart = "${spotifyd}/bin/spotifyd --no-daemon --config-path ${spotifydConf}"; + Restart = "always"; + RestartSec = 12; }; }; } diff --git a/dot/i3status-rust.nix b/dot/i3status-rust.nix index cb678f6..4055a02 100644 --- a/dot/i3status-rust.nix +++ b/dot/i3status-rust.nix @@ -97,9 +97,9 @@ in ${pkgs.newsboat}/bin/newsboat --execute=print-unread | ${pkgs.gawk}/bin/awk '{ print "📰 " $1 }' ''; on_click = setsid (pkgs.writers.writeDash "rss-update" '' - ${pkgs.libnotify}/bin/notify-send newsboat "Updating feeds. ♻" \ + ${pkgs.libnotify}/bin/notify-send --app-name=" Newsboat" "Updating feeds." \ && ${pkgs.newsboat}/bin/newsboat --execute=reload \ - && ${pkgs.libnotify}/bin/notify-send newsboat "Feeds updated. 📰" + && ${pkgs.libnotify}/bin/notify-send --app-name=" Newsboat" "Feeds updated." ''); } { @@ -114,9 +114,9 @@ in done | paste --serial --delimiters=" " - ''; on_click = setsid (pkgs.writers.writeDash "mail-update" '' - ${pkgs.libnotify}/bin/notify-send newsboat "Updating mail. ♻" \ - && ${pkgs.isync}/bin/mbsync -a \ - && ${pkgs.libnotify}/bin/notify-send newsboat "Mail updated. 📧" + ${pkgs.libnotify}/bin/notify-send --app-name="📧 MBSync" "Updating email." \ + && ${pkgs.isync}/bin/mbsync --all \ + && ${pkgs.libnotify}/bin/notify-send --app-name="📧 MBSync" "Email updated." ''); } {