tDisplay song filename if the file doesn't have any tags - spoon - dwm status utility (2f30 fork)
(HTM) git clone git://src.adamsgaard.dk/spoon
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit f73613f6c56516c7a3f36cc4e23b1861e563ff7d
(DIR) parent ec19af89f4a0e6851bdb3623e5c6e046af7be80a
(HTM) Author: sin <sin@2f30.org>
Date: Mon, 26 Sep 2016 16:26:53 +0100
Display song filename if the file doesn't have any tags
Diffstat:
M spoon.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/spoon.c b/spoon.c
t@@ -46,7 +46,7 @@ mpdread(char *buf, size_t len)
{
static struct mpd_connection *conn;
struct mpd_song *song;
- const char *artist, *title;
+ const char *artist, *title, *name;
int ret = 0;
if (conn == NULL) {
t@@ -69,8 +69,13 @@ mpdread(char *buf, size_t len)
} else if (title != NULL) {
strlcpy(buf, title, len);
} else {
- ret = -1;
- goto out;
+ name = mpd_song_get_uri(song);
+ if (name == NULL) {
+ mpd_song_free(song);
+ ret = -1;
+ goto out;
+ }
+ strlcpy(buf, name, len);
}
mpd_song_free(song);
if (!mpd_response_finish(conn)) {