From 70da1c8b370767e0d618571d9a9d803f3113e376 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 4 Mar 2011 19:29:52 +0100 Subject: [PATCH] Allow xmms2_smart to display only the title (sf.net #3140371) In the current implementation of xmms2_smart, when a song being played does not have an artist name (as is the case with many streams) conky displays an empty space a dash followed by the title (ex: " - Song Title"). The following patch improves this by only displaying the song title in xmms2_smart when the song artist is empty. Moreover, the patch also fixes an issue that existed with the previous xmms2_smart which seemed to be checking the string length of the song title twice before outputing the url of the song. This seems like a typo and what this line likely meant to do was check that both the song artist and song title were empty before displaying the song url. Patch contributed by Tamim Khan. Signed-off-by: Pavel Labath --- src/xmms2.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xmms2.cc b/src/xmms2.cc index d3159412..f6078d50 100644 --- a/src/xmms2.cc +++ b/src/xmms2.cc @@ -371,9 +371,12 @@ double xmms2_barval(struct text_object *obj) void print_xmms2_smart(struct text_object *obj, char *p, int p_max_size) { (void)obj; - if (strlen(info.xmms2.title) < 2 - && strlen(info.xmms2.title) < 2) { + int artist_len = strlen(info.xmms2.artist); + int title_len = strlen(info.xmms2.title); + if (artist_len < 2 && title_len < 2) { snprintf(p, p_max_size, "%s", info.xmms2.url); + } else if (artist_len < 1) { + snprintf(p, p_max_size, "%s", info.xmms2.title); } else { snprintf(p, p_max_size, "%s - %s", info.xmms2.artist, info.xmms2.title);