diff --git a/ChangeLog b/ChangeLog
index 6188a09f..d50107bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
* Adds a variable if_xmms2_connected to hide objects when xmms2d is not
running (thanks Lassi)
* Fix for buffer overflow with $execi (thanks Cesare)
+ * Fetch volume through Audacious API (thanks Erik)
2008-12-06
* Removed duplicate sanity check for diskio
diff --git a/doc/variables.xml b/doc/variables.xml
index 8029ba78..d0cb6636 100644
--- a/doc/variables.xml
+++ b/doc/variables.xml
@@ -240,6 +240,15 @@
Title of current tune with optional maximum length specifier
+
+
+
+
+
+
+ The current volume fetched from Audacious
+
+
diff --git a/src/audacious.c b/src/audacious.c
index e929a074..777c1a38 100644
--- a/src/audacious.c
+++ b/src/audacious.c
@@ -125,7 +125,7 @@ void *audacious_thread_func(void *pvoid)
{
static audacious_t items;
gint playpos, frames, length;
- gint rate, freq, chans;
+ gint rate, freq, chans, vol;
gchar *psong, *pfilename;
#ifndef AUDACIOUS_LEGACY
@@ -233,6 +233,11 @@ void *audacious_thread_func(void *pvoid)
/* Playlist position (index of song) */
snprintf(items[AUDACIOUS_PLAYLIST_POSITION],
sizeof(items[AUDACIOUS_PLAYLIST_POSITION]) - 1, "%d", playpos + 1);
+ /* Main volume */
+ vol = audacious_remote_get_main_volume(session);
+ snprintf(items[AUDACIOUS_MAIN_VOLUME],
+ sizeof(items[AUDACIOUS_MAIN_VOLUME]) - 1, "%d", vol);
+
} while (0);
/* Deliver the refreshed items array to audacious_items. */
timed_thread_lock(info.audacious.p_timed_thread);
diff --git a/src/audacious.h b/src/audacious.h
index 868185dd..430a85eb 100644
--- a/src/audacious.h
+++ b/src/audacious.h
@@ -37,10 +37,11 @@ enum _audacious_items {
AUDACIOUS_FILENAME,
AUDACIOUS_PLAYLIST_LENGTH,
AUDACIOUS_PLAYLIST_POSITION,
+ AUDACIOUS_MAIN_VOLUME,
};
/* 12 slots for the audacious values */
-typedef char audacious_t[12][128];
+typedef char audacious_t[13][128];
/* type for data exchange with main thread */
typedef struct audacious_s {
diff --git a/src/conky.c b/src/conky.c
index ecf033d8..2240befb 100644
--- a/src/conky.c
+++ b/src/conky.c
@@ -1373,6 +1373,7 @@ enum text_object_type {
OBJ_audacious_filename,
OBJ_audacious_playlist_length,
OBJ_audacious_playlist_position,
+ OBJ_audacious_main_volume,
OBJ_audacious_bar,
#endif
#ifdef BMPX
@@ -4071,6 +4072,7 @@ static struct text_object *construct_text_object(const char *s,
END OBJ(audacious_filename, INFO_AUDACIOUS)
END OBJ(audacious_playlist_length, INFO_AUDACIOUS)
END OBJ(audacious_playlist_position, INFO_AUDACIOUS)
+ END OBJ(audacious_main_volume, INFO_AUDACIOUS)
END OBJ(audacious_bar, INFO_AUDACIOUS)
scan_bar(arg, &obj->a, &obj->b);
#endif
@@ -6283,6 +6285,10 @@ static void generate_text_internal(char *p, int p_max_size,
snprintf(p, p_max_size, "%s",
cur->audacious.items[AUDACIOUS_PLAYLIST_POSITION]);
}
+ OBJ(audacious_main_volume) {
+ snprintf(p, p_max_size, "%s",
+ cur->audacious.items[AUDACIOUS_MAIN_VOLUME]);
+ }
OBJ(audacious_bar) {
double progress;