meta: Replace ncmpcpp song change script with mpdris2-rs

This greatly simplifies the config and enables the usage of song change
notifications outside of ncmpcpp.
This commit is contained in:
Donovan Glover 2024-07-11 07:57:55 -04:00
parent 7ae7af253c
commit 8fb63f0712
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 1 additions and 29 deletions

View File

@ -76,6 +76,7 @@ in
"wpctl set-volume @DEFAULT_AUDIO_SINK@ 20%"
"ironbar"
"fcitx5"
"mpdris2-rs"
"hyprctl dispatch workspace 5000000"
"${polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"
"hyprdim --no-dim-when-only --persist --ignore-leaving-special --dialog-dim"

View File

@ -5,8 +5,6 @@ let
inherit (config.xdg.userDirs) music;
musicDirectory = music;
changeScript = "ncmpcpp/on-song-change.sh";
fallbackImage = ../assets/wallpaper.png;
in
{
home.packages = [ mpc-cli ];
@ -20,32 +18,6 @@ in
'';
};
xdg.configFile.${changeScript} = {
executable = true;
text = /* bash */ ''
#!/usr/bin/env bash
find_cover () {
ext="$(mpc --format %file% current | sed 's/^.*\.//')"
if [ "$ext" == "flac" ]; then
metaflac --export-picture-to=/tmp/cover.jpg \
"$(mpc --format "${musicDirectory}"/%file% current)" && cover_path="/tmp/cover.jpg" && return
else
ffmpeg -y -i "$(mpc --format "${musicDirectory}"/%file% | head -n 1)" \
/tmp/cover.jpg && cover_path="/tmp/cover.jpg" && return
fi
file="${musicDirectory}/$(mpc --format %file% current)"
album="''${file%/*}"
cover_path=$(find "$album" -maxdepth 1 | grep -m 1 ".*\.\(jpg\|png\|gif\|bmp\)")
}
find_cover 2>/dev/null
notify-send -i "''${cover_path:-${fallbackImage}}" "Now Playing" "$(mpc current)" 2>/dev/null
'';
};
programs.ncmpcpp = {
enable = true;
@ -86,7 +58,6 @@ in
autocenter_mode = "yes";
allow_for_physical_item_deletion = "no";
mouse_support = "no";
execute_on_song_change = "~/.config/${changeScript}";
mpd_crossfade_time = 3;
};
};