Introduction
Introduction Statistics Contact Development Disclaimer Help
Show an animation instead of a long URI when no tags - spoon - set dwm status
git clone git://git.codemadness.org/spoon
Log
Files
Refs
LICENSE
---
commit cb6af3adecc068b161a43a20103221498a228bcf
parent 34037d775918f2fcb5f0efc395cf786da46bd79e
Author: lostd <[email protected]>
Date: Wed, 2 Nov 2016 16:43:35 +0000
Show an animation instead of a long URI when no tags
Diffstat:
M mpd.c | 18 +++++++++++-------
M spoon.c | 2 +-
M 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)
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.