spoon

set dwm status
git clone git://git.2f30.org/spoon.git
Log | Files | Refs | LICENSE

commit cb6af3adecc068b161a43a20103221498a228bcf
parent 34037d775918f2fcb5f0efc395cf786da46bd79e
Author: lostd <lostd@2f30.org>
Date:   Wed Nov  2 16:43:35 +0000

Show an animation instead of a long URI when no tags

Diffstat:
mpd.c | 18+++++++++++-------
spoon.c | 2+-
util.h | 2++
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/mpd.c b/mpd.c @@ -6,13 +6,22 @@ #include "types.h" #include "util.h" +char *anim[] = { + "!!.|.", + "|!.!.", + "!.!!.", + "!!|.!", + ".!!|!", +}; + int mpdread(void *arg, char *buf, size_t len) { static struct mpd_connection *conn; struct mpd_song *song; - const char *artist, *title, *name; + const char *artist, *title; struct mpdarg *mpdarg = arg; + static int frame = 0; if (conn == NULL) { conn = mpd_connection_new(mpdarg->host, mpdarg->port, 0); @@ -36,12 +45,7 @@ mpdread(void *arg, char *buf, size_t len) } else if (title != NULL) { strlcpy(buf, title, len); } else { - name = mpd_song_get_uri(song); - if (name == NULL) { - mpd_song_free(song); - goto out; - } - strlcpy(buf, name, len); + strlcpy(buf, anim[frame++ % LEN(anim)], len); } mpd_song_free(song); if (!mpd_response_finish(conn)) diff --git a/spoon.c b/spoon.c @@ -5,7 +5,7 @@ #include <X11/Xlib.h> -#define LEN(x) (sizeof (x) / sizeof *(x)) +#include "util.h" int battread(void *, char *, size_t); int cpuread(void *, char *, size_t); diff --git a/util.h b/util.h @@ -3,6 +3,8 @@ size_t strlcat(char *, const char *, size_t); #undef strlcpy size_t strlcpy(char *, const char *, size_t); +#define LEN(x) (sizeof (x) / sizeof *(x)) + #ifdef DEBUG #define DPRINTF_S(x) printf(#x "=%s\n", x) #define DPRINTF_U(x) printf(#x "=%u\n", x)