status

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

Commit: 4085b1cd974a755f36533fd4dfc6e392404f590d
Parent: 0909d9808ba1942660ab52b2921bf70b7fa51113
Author: Randy Palamar
Date:   Sat,  3 Apr 2021 20:33:31 -0600

try to restart connection if mpd is killed

*conn will be reset to NULL in the call to openconn() if the conn fails
so there is no need to do it after the free()

Diffstat:
Mblocks/mpd.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/blocks/mpd.c b/blocks/mpd.c @@ -29,6 +29,12 @@ mpd(struct Block *b) if (!conn && openconn() != 0) return snprintf(b->curstr, BLOCKLEN, b->fmt, ""); + if (mpd_connection_get_error(conn)) { + mpd_connection_free(conn); + if (openconn() != 0) + return snprintf(b->curstr, BLOCKLEN, b->fmt, ""); + } + if (mpd_send_status(conn)) status = mpd_recv_status(conn);