From afcae6eba54d7db21bab7d40bb2a4560d5696ecf Mon Sep 17 00:00:00 2001 From: Philip Kovacs Date: Fri, 1 Dec 2006 00:29:12 +0000 Subject: [PATCH] add max_length to audacious_title git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@800 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 2 ++ README | 4 ++-- doc/conky.1 | 4 ++-- doc/variables.xml | 3 ++- src/conky.c | 19 ++++++++++++++++--- src/conky.h | 1 + 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dcf72a60..28ce59ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ * Added $entropy_avail, $entropy_poolsize and $entropy_bar for the crypto freaks. Idea suggested by Perttu Luukko in feature request 1497050. + * Added max length specifier to audacious_title. Closes + feature request #1600631. 2006-11-28 * Rearrange retry attempts in pop3 and imap code, removing sleep() diff --git a/README b/README index d894dff5..b41459ae 100644 --- a/README +++ b/README @@ -464,8 +464,8 @@ VARIABLES Player status (Playing/Paused/Stopped/Not running) - audacious_title - Title of current tune + audacious_title (max length) + Title of current tune with optional maximum length specifier battery (num) diff --git a/doc/conky.1 b/doc/conky.1 index 644d9339..defeb5c3 100644 --- a/doc/conky.1 +++ b/doc/conky.1 @@ -440,8 +440,8 @@ Position of current tune in seconds Player status (Playing/Paused/Stopped/Not running) .TP -\fB\*(T<\fBaudacious_title\fR\*(T>\fR -Title of current tune +\fB\*(T<\fBaudacious_title\fR\*(T>\fR \*(T<\fB(max length)\fR\*(T> +Title of current tune with optional maximum length specifier .TP \fB\*(T<\fBbattery\fR\*(T>\fR \*(T<\fB(num)\fR\*(T> diff --git a/doc/variables.xml b/doc/variables.xml index 9c5ab0df..358ff039 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -223,9 +223,10 @@ + - Title of current tune + Title of current tune with optional maximum length specifier diff --git a/src/conky.c b/src/conky.c index ade1f8e7..3c87f042 100644 --- a/src/conky.c +++ b/src/conky.c @@ -2828,7 +2828,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg, END OBJ(xmms2_date, INFO_XMMS2) END OBJ(xmms2_id, INFO_XMMS2) END OBJ(xmms2_duration, INFO_XMMS2) - END OBJ(xmms2_elapsed, INFO_XMMS2) + END OBJ(xmms2_elapsed, INFO_XMMS2) END OBJ(xmms2_size, INFO_XMMS2) END OBJ(xmms2_status, INFO_XMMS2) END OBJ(xmms2_percent, INFO_XMMS2) @@ -2839,7 +2839,18 @@ static struct text_object *construct_text_object(const char *s, const char *arg, #endif #ifdef AUDACIOUS OBJ(audacious_status, INFO_AUDACIOUS) END - OBJ(audacious_title, INFO_AUDACIOUS) END + OBJ(audacious_title, INFO_AUDACIOUS) + { + if (arg) + { + sscanf (arg, "%d", &info.audacious.max_title_len); + if (info.audacious.max_title_len > 0) + info.audacious.max_title_len++; + else + CRIT_ERR ("audacious_title: invalid length argument"); + } + } + END OBJ(audacious_length, INFO_AUDACIOUS) END OBJ(audacious_length_seconds, INFO_AUDACIOUS) END OBJ(audacious_position, INFO_AUDACIOUS) END @@ -4430,7 +4441,9 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object * snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_STATUS]); } OBJ(audacious_title) { - snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_TITLE]); + snprintf(p, cur->audacious.max_title_len > 0 ? + cur->audacious.max_title_len : p_max_size, "%s", + cur->audacious.items[AUDACIOUS_TITLE]); } OBJ(audacious_length) { snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_LENGTH]); diff --git a/src/conky.h b/src/conky.h index 4693df71..18b33fca 100644 --- a/src/conky.h +++ b/src/conky.h @@ -170,6 +170,7 @@ struct xmms2_s { #ifdef AUDACIOUS struct audacious_s { audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */ + int max_title_len; /* e.g. ${audacious_title 50} */ timed_thread *p_timed_thread; }; #endif