From 58347fdfe21315ad3ccc0bd7c4703a8ec7aae797 Mon Sep 17 00:00:00 2001 From: tdback Date: Wed, 4 Dec 2024 18:50:37 -0500 Subject: initial commit to new repo --- mpc_update | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 mpc_update (limited to 'mpc_update') diff --git a/mpc_update b/mpc_update new file mode 100755 index 0000000..53adf2b --- /dev/null +++ b/mpc_update @@ -0,0 +1,26 @@ +#!/bin/sh + +# mpc_update: Update an mpd playlist to include new songs in the music +# directory. + +yell() { echo "$0: $*" >&2; } +die() { yell "$*"; exit 111; } +try() { "$@" || die "cannot $*"; } + +[ "$#" -ne 2 ] && echo "usage: mpc_update " >&2 + +PLAYLIST="$1" +MUSIC_DIR="$2" + +[ -d "$MUSIC_DIR" ] && cd "$MUSIC_DIR" || + die "music directory '$MUSIC_DIR' does not exist!" + +# Clear the current playlist to prevent song duplication in mpd. +[ -e "$HOME/.local/share/mpd/playlists/${PLAYLIST}.m3u" ] && + try mpc clear >/dev/null && + try mpc rm "$PLAYLIST" + +# Add every song in the music directory. +try mpc add -- * + +try mpc save "$PLAYLIST" -- cgit v1.2.3