From 94370b149fa505c9aeb2c37996419fd7f91588d1 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 10 Aug 2024 14:47:00 +0200 Subject: fix(pkgs/mpc): Update the new music handling system --- pkgs/by-name/ly/lyrics/lyrics.sh | 11 ----------- pkgs/by-name/ly/lyrics/package.nix | 27 -------------------------- pkgs/by-name/mp/mpc-fav/mpc-fav.sh | 16 --------------- pkgs/by-name/mp/mpc-fav/package.nix | 13 ------------- pkgs/by-name/mp/mpc-lyrics/mpc-lyrics.sh | 11 +++++++++++ pkgs/by-name/mp/mpc-lyrics/package.nix | 27 ++++++++++++++++++++++++++ pkgs/by-name/mp/mpc-rm/mpc-rm.sh | 5 +++-- pkgs/by-name/mp/mpc-rm/package.nix | 5 +++-- pkgs/by-name/mp/mpc-searchadd/mpc-searchadd.sh | 14 +++++++++++++ pkgs/by-name/mp/mpc-searchadd/package.nix | 16 +++++++++++++++ pkgs/by-name/mp/mpc/mpc.sh | 12 ++++++++---- pkgs/by-name/mp/mpc/package.nix | 8 +++----- 12 files changed, 85 insertions(+), 80 deletions(-) delete mode 100755 pkgs/by-name/ly/lyrics/lyrics.sh delete mode 100644 pkgs/by-name/ly/lyrics/package.nix delete mode 100755 pkgs/by-name/mp/mpc-fav/mpc-fav.sh delete mode 100644 pkgs/by-name/mp/mpc-fav/package.nix create mode 100755 pkgs/by-name/mp/mpc-lyrics/mpc-lyrics.sh create mode 100644 pkgs/by-name/mp/mpc-lyrics/package.nix create mode 100755 pkgs/by-name/mp/mpc-searchadd/mpc-searchadd.sh create mode 100644 pkgs/by-name/mp/mpc-searchadd/package.nix (limited to 'pkgs') diff --git a/pkgs/by-name/ly/lyrics/lyrics.sh b/pkgs/by-name/ly/lyrics/lyrics.sh deleted file mode 100755 index 004c67c7..00000000 --- a/pkgs/by-name/ly/lyrics/lyrics.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -( - cd "%MPD_MUSIC_DIR" || die "No music dir!" - exiftool "$(mpc --format '%file%' current)" -json | jq '.[0].Lyrics' -r | less -) - -# vim: ft=sh diff --git a/pkgs/by-name/ly/lyrics/package.nix b/pkgs/by-name/ly/lyrics/package.nix deleted file mode 100644 index d83057ce..00000000 --- a/pkgs/by-name/ly/lyrics/package.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - sysLib, - exiftool, - mpc-cli, - jq, - less, - locale, # dependency of less - mpd_music_dir ? "\${XDG_MUSIC_DIR}", -}: -sysLib.writeShellScript { - name = "lyrics"; - src = ./lyrics.sh; - generateCompletions = false; - keepPath = false; - - replacementStrings = { - MPD_MUSIC_DIR = mpd_music_dir; - }; - - dependencies = [ - exiftool - mpc-cli - jq - less - locale # dependency of less - ]; -} diff --git a/pkgs/by-name/mp/mpc-fav/mpc-fav.sh b/pkgs/by-name/mp/mpc-fav/mpc-fav.sh deleted file mode 100755 index 795a4875..00000000 --- a/pkgs/by-name/mp/mpc-fav/mpc-fav.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites" - -cd "$XDG_MUSIC_DIR" || die "No music dir!" - -[ -d "$FAV_DIR" ] || mkdir --parents "$FAV_DIR" - -ln -sr "$(mpc --format '%file%' current)" "$FAV_DIR/" || die "Link failed!" - -mpc update - -# vim: ft=sh diff --git a/pkgs/by-name/mp/mpc-fav/package.nix b/pkgs/by-name/mp/mpc-fav/package.nix deleted file mode 100644 index 2d3a8f3f..00000000 --- a/pkgs/by-name/mp/mpc-fav/package.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - sysLib, - mpc-cli, -}: -sysLib.writeShellScript { - name = "mpc-fav"; - src = ./mpc-fav.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ - mpc-cli - ]; -} diff --git a/pkgs/by-name/mp/mpc-lyrics/mpc-lyrics.sh b/pkgs/by-name/mp/mpc-lyrics/mpc-lyrics.sh new file mode 100755 index 00000000..004c67c7 --- /dev/null +++ b/pkgs/by-name/mp/mpc-lyrics/mpc-lyrics.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH + +( + cd "%MPD_MUSIC_DIR" || die "No music dir!" + exiftool "$(mpc --format '%file%' current)" -json | jq '.[0].Lyrics' -r | less +) + +# vim: ft=sh diff --git a/pkgs/by-name/mp/mpc-lyrics/package.nix b/pkgs/by-name/mp/mpc-lyrics/package.nix new file mode 100644 index 00000000..fdb8c53a --- /dev/null +++ b/pkgs/by-name/mp/mpc-lyrics/package.nix @@ -0,0 +1,27 @@ +{ + sysLib, + exiftool, + mpc-cli, + jq, + less, + locale, # dependency of less + mpd_music_dir ? "\${XDG_MUSIC_DIR}", +}: +sysLib.writeShellScript { + name = "mpc-lyrics"; + src = ./mpc-lyrics.sh; + generateCompletions = false; + keepPath = false; + + replacementStrings = { + MPD_MUSIC_DIR = mpd_music_dir; + }; + + dependencies = [ + exiftool + mpc-cli + jq + less + locale # dependency of less + ]; +} diff --git a/pkgs/by-name/mp/mpc-rm/mpc-rm.sh b/pkgs/by-name/mp/mpc-rm/mpc-rm.sh index 94e0634b..3209503c 100755 --- a/pkgs/by-name/mp/mpc-rm/mpc-rm.sh +++ b/pkgs/by-name/mp/mpc-rm/mpc-rm.sh @@ -3,8 +3,9 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH -cd "$XDG_MUSIC_DIR" || die "No music dir!" -trash-put "$(mpc --format '%file%' current)" +beet remove --delete \ + title:"$(mpc --format '%title%' current)" \ + album:"$(mpc --format '%album%' current)" mpc del 0 # vim: ft=sh diff --git a/pkgs/by-name/mp/mpc-rm/package.nix b/pkgs/by-name/mp/mpc-rm/package.nix index 6b7e2ead..8af84279 100644 --- a/pkgs/by-name/mp/mpc-rm/package.nix +++ b/pkgs/by-name/mp/mpc-rm/package.nix @@ -1,15 +1,16 @@ { sysLib, mpc-cli, - trash-cli, + beets, }: sysLib.writeShellScript { name = "mpc-rm"; src = ./mpc-rm.sh; generateCompletions = false; keepPath = false; + dependencies = [ mpc-cli - trash-cli + beets ]; } diff --git a/pkgs/by-name/mp/mpc-searchadd/mpc-searchadd.sh b/pkgs/by-name/mp/mpc-searchadd/mpc-searchadd.sh new file mode 100755 index 00000000..3fe9a6b6 --- /dev/null +++ b/pkgs/by-name/mp/mpc-searchadd/mpc-searchadd.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH + +tracks="$(mktmp)" +beet list "$@" --path >"$tracks" + +while read -r track; do + mpc add "$track" +done <"$tracks" + +mpc playlist +# vim: ft=sh diff --git a/pkgs/by-name/mp/mpc-searchadd/package.nix b/pkgs/by-name/mp/mpc-searchadd/package.nix new file mode 100644 index 00000000..54ceca91 --- /dev/null +++ b/pkgs/by-name/mp/mpc-searchadd/package.nix @@ -0,0 +1,16 @@ +{ + sysLib, + mpc-cli, + beets, +}: +sysLib.writeShellScript { + name = "mpc-searchadd"; + src = ./mpc-searchadd.sh; + generateCompletions = false; + keepPath = false; + + dependencies = [ + mpc-cli + beets + ]; +} diff --git a/pkgs/by-name/mp/mpc/mpc.sh b/pkgs/by-name/mp/mpc/mpc.sh index 5aae5cdb..f613cf0a 100755 --- a/pkgs/by-name/mp/mpc/mpc.sh +++ b/pkgs/by-name/mp/mpc/mpc.sh @@ -4,13 +4,17 @@ SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH case "$1" in -"rm") +"searchadd") shift 1 - mpc-rm "$@" + mpc-searchadd "$@" + ;; +"lyrics") + shift 1 + mpc-lyrics "$@" ;; -"fav") +"rm") shift 1 - mpc-fav "$@" + mpc-rm "$@" ;; *) mpc "$@" diff --git a/pkgs/by-name/mp/mpc/package.nix b/pkgs/by-name/mp/mpc/package.nix index 936aa990..d73c0523 100644 --- a/pkgs/by-name/mp/mpc/package.nix +++ b/pkgs/by-name/mp/mpc/package.nix @@ -1,17 +1,15 @@ { sysLib, - mpc-fav, - mpc-rm, mpc-cli, }: sysLib.writeShellScript { name = "mpc"; src = ./mpc.sh; generateCompletions = false; - keepPath = false; + # We source the wrappers from the environment, to ensure that they have the same + # configurations (e.g. MPD_MUSIC_DIR in `mpc-lyrics`) + keepPath = true; dependencies = [ - mpc-fav - mpc-rm mpc-cli ]; } -- cgit 1.4.1