1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-16 01:57:09 +00:00

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 <pavelo@centrum.sk>
This commit is contained in:
Pavel Labath 2011-03-04 19:29:52 +01:00
parent cb544bd1f7
commit 70da1c8b37

View File

@ -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 print_xmms2_smart(struct text_object *obj, char *p, int p_max_size)
{ {
(void)obj; (void)obj;
if (strlen(info.xmms2.title) < 2 int artist_len = strlen(info.xmms2.artist);
&& strlen(info.xmms2.title) < 2) { int title_len = strlen(info.xmms2.title);
if (artist_len < 2 && title_len < 2) {
snprintf(p, p_max_size, "%s", info.xmms2.url); snprintf(p, p_max_size, "%s", info.xmms2.url);
} else if (artist_len < 1) {
snprintf(p, p_max_size, "%s", info.xmms2.title);
} else { } else {
snprintf(p, p_max_size, "%s - %s", info.xmms2.artist, snprintf(p, p_max_size, "%s - %s", info.xmms2.artist,
info.xmms2.title); info.xmms2.title);