commit b7d243edf97254cf05ab96bb2a5b1acf0a25331d
parent bc801af9e3635c64d212ad96485a3ad15b793406
Author: mtmn <miro@haravara.org>
Date: Sun, 18 Oct 2026 16:03:12 +0200
remove hawk-watch, fix mpd_add_to_playlist
Diffstat:
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/mpd/README.md b/mpd/README.md
@@ -9,7 +9,7 @@ starting with `#` are ignored. Use `-` for stdin.
| Command | Usage | Purpose |
|---------|-------|---------|
| `mpd_add_to_queue` | `[--verbose] [FILE\|-]` | Append tracks to the queue. |
-| `mpd_add_to_playlist` | `[--verbose] PLAYLIST [FILE\|-]` | Add tracks to a stored playlist; with terminal stdin, add the current song. |
+| `mpd_add_to_playlist` | `[--verbose] PLAYLIST [FILE\|-]` | Add tracks from FILE or stdin (`-`) to a stored playlist; without FILE, add the current song. |
| `mpd_edit_queue` | `[--force]` | Edit the queue with `$VISUAL`, `$EDITOR`, or `vi`. |
| `mpd_edit_playlist` | `[--force] PLAYLIST` | Edit a stored playlist. |
| `mpd_insert_next` | `[--verbose] [FILE\|-]` | Insert tracks after the current song, or at the front. |
diff --git a/mpd/mpd_add_to_playlist.c b/mpd/mpd_add_to_playlist.c
@@ -3,7 +3,6 @@
#include "mpd_common.h"
#include <string.h>
-#include <unistd.h>
static void usage(FILE *file, const char *program) {
fprintf(file, "Usage: %s [--verbose] PLAYLIST [FILE|-]\n", program);
@@ -43,7 +42,7 @@ int main(int argc, char **argv) {
bool ok = true;
size_t count = 0U;
- if (path == NULL && isatty(STDIN_FILENO)) {
+ if (path == NULL) {
connection = mt_connect();
if (connection == NULL)
return 1;
@@ -85,6 +84,10 @@ int main(int argc, char **argv) {
ok = false;
if (ok && tracks.len > 0U)
ok = mt_add_playlist(connection, playlist, &tracks, verbose);
+ if (ok && count == 0U) {
+ fprintf(stderr, "mpd: no tracks to add to %s\n", playlist);
+ ok = false;
+ }
if (ok)
printf("Added %zu track%s to %s.\n", count, count == 1U ? "" : "s",
playlist);
diff --git a/mpd/tests/test_mpd_tools.py b/mpd/tests/test_mpd_tools.py
@@ -397,7 +397,7 @@ class MPDToolsTest(unittest.TestCase):
def test_playlist_add_and_edit(self):
result = self.run_tool(
- "mpd_add_to_playlist", "favorites", input_text="one\ntwo\n"
+ "mpd_add_to_playlist", "favorites", "-", input_text="one\ntwo\n"
)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(self.server.state.playlists["favorites"], ["one", "two"])