From 61053ab09a52c4a0ca36ed4e7eb01cc8a26463d9 Mon Sep 17 00:00:00 2001 From: "J. Alexander Treuman" Date: Sun, 21 Sep 2008 19:37:43 +0200 Subject: [PATCH] added optional bitrate display to status bar If visible-bitrate is enabled, then the current bitrate will be drawn next to the song time in the status bar. By default it will not be displayed. --- src/conf.c | 5 +++++ src/options.h | 1 + src/screen.c | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/conf.c b/src/conf.c index 970bc08..ac48e9c 100644 --- a/src/conf.c +++ b/src/conf.c @@ -70,6 +70,7 @@ #define CONF_SHOW_SPLASH "show-splash" #define CONF_SCROLL "scroll" #define CONF_SCROLL_SEP "scroll-sep" +#define CONF_VISIBLE_BITRATE "visible-bitrate" typedef enum { KEY_PARSER_UNKNOWN, @@ -462,6 +463,10 @@ read_rc_file(char *filename, options_t *options) { options->wide_cursor = str2bool(value); } + /* visible bitrate */ + else if (!strcasecmp(CONF_VISIBLE_BITRATE, name)) { + options->visible_bitrate = str2bool(value); + } /* timer display type */ else if( !strcasecmp(CONF_TIMEDISPLAY_TYPE, name) ) { diff --git a/src/options.h b/src/options.h index d0a068f..58eaff1 100644 --- a/src/options.h +++ b/src/options.h @@ -37,6 +37,7 @@ typedef struct { gboolean enable_xterm_title; gboolean enable_mouse; gboolean scroll; + gboolean visible_bitrate; } options_t; #ifndef NO_GLOBAL_OPTIONS diff --git a/src/screen.c b/src/screen.c index 2a5d641..c526e66 100644 --- a/src/screen.c +++ b/src/screen.c @@ -317,6 +317,7 @@ paint_status_window(mpdclient_t *c) mpd_Status *status = c->status; mpd_Song *song = c->song; int elapsedTime = 0; + char bitrate[16]; const char *str = NULL; int x = 0; @@ -357,16 +358,25 @@ paint_status_window(mpdclient_t *c) if( c->song && seek_id == c->song->id ) elapsedTime = seek_target_time; + + /* display bitrate if visible-bitrate is true */ + if (options.visible_bitrate) { + g_snprintf(bitrate, 16, + " [%d kbps]", status->bitRate); + } else { + bitrate[0] = '\0'; + } + /*write out the time, using hours if time over 60 minutes*/ if (c->status->totalTime > 3600) { g_snprintf(screen.buf, screen.buf_size, - " [%i:%02i:%02i/%i:%02i:%02i]", - elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60, + "%s [%i:%02i:%02i/%i:%02i:%02i]", + bitrate, elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60, status->totalTime/3600, (status->totalTime%3600)/60, status->totalTime%60); } else { g_snprintf(screen.buf, screen.buf_size, - " [%i:%02i/%i:%02i]", - elapsedTime/60, elapsedTime%60, + "%s [%i:%02i/%i:%02i]", + bitrate, elapsedTime/60, elapsedTime%60, status->totalTime/60, status->totalTime%60 ); } } else { -- 2.30.2