Fetch volume through Audacious API (thanks Erik)
authorErik Waling <erikw@acc.umu.se>
Sun, 7 Dec 2008 07:38:06 +0000 (00:38 -0700)
committerBrenden Matthews <brenden@rty.ca>
Sun, 7 Dec 2008 07:38:06 +0000 (00:38 -0700)
ChangeLog
doc/variables.xml
src/audacious.c
src/audacious.h
src/conky.c

index 6188a09..d50107b 100644 (file)
--- 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
index 8029ba7..d0cb663 100644 (file)
                        Title of current tune with optional maximum length specifier
                        <para></para></listitem>
        </varlistentry>
+       
+       <varlistentry>
+               <term>
+                       <command><option>audacious_main_volume</option></command>
+               </term>
+               <listitem>
+                       The current volume fetched from Audacious
+                       <para></para></listitem>
+       </varlistentry>
 
        <varlistentry>
                <term>
index e929a07..777c1a3 100644 (file)
@@ -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);
index 868185d..430a85e 100644 (file)
@@ -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 {
index ecf033d..2240bef 100644 (file)
@@ -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;