status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

Commit: e4a8f106d1ac06e3dcc4407eeb367035bb7a187c
Parent: d4a2564d6892003387bb3ba1c435620333c53969
Author: Randy Palamar
Date:   Sun,  4 Apr 2021 16:46:08 -0600

make conn test clearer and rename mpd() to mpd_tag()

Diffstat:
Mblocks/mpd.c | 16++++++++--------
Mblocks/mpd.h | 3++-
Mconfig.def.h | 4++--
3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/blocks/mpd.c b/blocks/mpd.c @@ -12,14 +12,14 @@ static int open_conn(void) { conn = mpd_connection_new(mpdhost, 0, 0); - if (mpd_connection_get_error(conn) - || !mpd_connection_set_keepalive(conn, true)) { - mpd_connection_free(conn); - conn = NULL; - return -1; + if (!mpd_connection_get_error(conn) + && mpd_connection_set_keepalive(conn, true)) { + mpd_send_idle(conn); + return 0; } - mpd_send_idle(conn); - return 0; + mpd_connection_free(conn); + conn = NULL; + return -1; } static int @@ -33,7 +33,7 @@ check_conn(void) } size_t -mpd(struct Block *b) +mpd_tag(struct Block *b) { struct mpd_song *song = NULL; struct mpd_status *status = NULL; diff --git a/blocks/mpd.h b/blocks/mpd.h @@ -2,4 +2,5 @@ #include <mpd/tag.h> extern const char *mpdhost; -size_t mpd(struct Block *b); + +size_t mpd_tag(struct Block *b); diff --git a/config.def.h b/config.def.h @@ -14,8 +14,8 @@ const char *alsacard = "default"; /* status block definitions */ struct Block blks[] = { /* fn fmt interval signal arg */ - { mpd, "[ %s ", 0, 1, { .i = MPD_TAG_ARTIST } }, - { mpd, "- %s ]", 0, 1, { .i = MPD_TAG_TITLE } }, + { mpd_tag, "[ %s ", 0, 1, { .i = MPD_TAG_ARTIST } }, + { mpd_tag, "- %s ]", 0, 1, { .i = MPD_TAG_TITLE } }, { batinfo, "[ %s ]", 30, 0, { .s = "BAT0" } }, { getvol, "[ %s ]", 0, 2, { .s = "Speaker" } }, { gettime, "[ %R ]", 20, 0, {0} },