Roman Bogorodskiy <novel at clublife dot ru>
FreeBSD support
+ BMPx support
Szymon Boniecki
Reads current LC_TIME
# $Id$
+2005-12-30
+ * Added BMPx (http://beep-media-player.org/) support
+
2005-12-14
* Fixed issues with execi stuff
fi
dnl
+dnl BMPx
+dnl
+
+want_bmpx=no
+AC_ARG_ENABLE(bmpx,
+ [ --enable-bmpx enable if you want BMPx support [[default=no]]],
+ [want_bmpx="$enableval"])
+
+AM_CONDITIONAL(BUILD_BMPX, test x$want_bmpx = xyes)
+if test x$want_bmpx = xyes; then
+ PKG_CHECK_MODULES([DBUS], [dbus-1 >= 0.35 dbus-glib-1 >= 0.35])
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ AC_DEFINE(BMPX, 1, [Define if you want BMPx support])
+fi
+
+dnl
dnl Seti@Home
dnl
bin_PROGRAMS = conky
+if BUILD_BMPX
+bmpx = bmpx.c
+endif
+
if BUILD_SETI
seti = seti.c
endif
x11 = x11.c
endif
-conky_SOURCES = common.c fs.c $(linux) mail.c mixer.c $(seti) $(mpd) $(solaris) $(freebsd) $(netbsd) $(port_monitors) conky.c conky.h $(x11) $(mldonkey) remoted.c remoted.h remotec.c remotec.h
+conky_SOURCES = common.c fs.c $(linux) mail.c mixer.c $(seti) $(mpd) $(solaris) $(freebsd) $(netbsd) $(port_monitors) conky.c conky.h $(x11) $(mldonkey) remoted.c remoted.h remotec.c remotec.h $(bmpx)
AM_LDFLAGS = $(X11_LIBS) $(XFT_LIBS) $(CAIRO_LIBS) $(PTHREAD_LIBS) -lm
--- /dev/null
+/** bmpx.c
+ * BMPx client
+ *
+ * $Id$
+ */
+
+#include <dbus/dbus-glib.h>
+#include <bmpx/dbus.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "conky.h"
+
+#define DBUS_TYPE_G_STRING_VALUE_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
+
+static DBusGConnection *bus;
+static DBusGProxy *remote_object;
+static int connected = 0;
+
+void update_bmpx()
+{
+ GError *error = NULL;
+ struct information *current_info = &info;
+ gchar *uri;
+ GHashTable *metadata;
+
+ if (connected == 0) {
+ g_type_init();
+ dbus_g_type_specialized_init();
+
+ bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ if (bus == NULL) {
+ ERR("%s\n", error->message);
+ }
+
+ remote_object = dbus_g_proxy_new_for_name(bus,
+ BMP_DBUS_SERVICE,
+ BMP_DBUS_PATH_SYSTEMCONTROL,
+ BMP_DBUS_INTERFACE);
+ if (!remote_object) {
+ ERR("%s\n", error->message);
+ goto fail;
+ } else
+ connected = 1;
+ }
+
+ if (connected == 1) {
+ if (dbus_g_proxy_call(remote_object, "GetCurrentUri", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &uri, G_TYPE_INVALID)) {
+ current_info->bmpx.uri = uri;
+ } else {
+ ERR("%s\n", error->message);
+ goto fail;
+ }
+
+ if (dbus_g_proxy_call(remote_object, "GetMetadataForUri", &error,
+ G_TYPE_STRING,
+ uri,
+ G_TYPE_INVALID,
+ DBUS_TYPE_G_STRING_VALUE_HASHTABLE,
+ &metadata,
+ G_TYPE_INVALID)) {
+ current_info->bmpx.title= g_value_get_string(g_hash_table_lookup(metadata, "title"));
+ current_info->bmpx.artist = g_value_get_string(g_hash_table_lookup(metadata, "artist"));
+ current_info->bmpx.album = g_value_get_string(g_hash_table_lookup(metadata, "album"));
+ current_info->bmpx.bitrate = g_value_get_int(g_hash_table_lookup(metadata, "bitrate"));
+ current_info->bmpx.track = g_value_get_int(g_hash_table_lookup(metadata, "track-number"));
+ } else {
+ ERR("%s\n", error->message);
+ goto fail;
+ }
+
+ if (uri)
+ free(uri);
+ g_hash_table_destroy(metadata);
+ } else {
+fail:
+ current_info->bmpx.title = strdup("Unknown");
+ current_info->bmpx.artist = strdup("Unknown");
+ current_info->bmpx.album = strdup("Unknown");
+ current_info->bmpx.bitrate = 0;
+ current_info->bmpx.track = 0;
+ }
+}
if (NEED(INFO_MPD))
update_mpd();
#endif
-
+#ifdef BMPX
+ if (NEED(INFO_BMPX))
+ update_bmpx();
+#endif
+
if (NEED(INFO_LOADAVG))
update_load_average();
OBJ_mpd_track,
OBJ_mpd_percent,
#endif
+#ifdef BMPX
+ OBJ_bmpx_title,
+ OBJ_bmpx_artist,
+ OBJ_bmpx_album,
+ OBJ_bmpx_track,
+ OBJ_bmpx_uri,
+ OBJ_bmpx_bitrate,
+#endif
#ifdef TCP_PORT_MONITOR
OBJ_tcp_portmon,
#endif
case OBJ_mpd_status:
case OBJ_mpd_host:
#endif
+#ifdef BMPX
+ case OBJ_bmpx_title:
+ case OBJ_bmpx_artist:
+ case OBJ_bmpx_album:
+ case OBJ_bmpx_track:
+ case OBJ_bmpx_uri:
+ case OBJ_bmpx_bitrate:
+#endif
case OBJ_pre_exec:
case OBJ_battery:
free(objs[i].data.s);
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END
#endif
+#ifdef BMPX
+ OBJ(bmpx_title, INFO_BMPX)
+ END
+ OBJ(bmpx_artist, INFO_BMPX)
+ END
+ OBJ(bmpx_album, INFO_BMPX)
+ END
+ OBJ(bmpx_track, INFO_BMPX)
+ END
+ OBJ(bmpx_uri, INFO_BMPX)
+ END
+ OBJ(bmpx_bitrate, INFO_BMPX)
+ END
+#endif
#ifdef TCP_PORT_MONITOR
OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR)
int argc, port_begin, port_end, item, connection_index;
255.0f));
}
#endif
+#ifdef BMPX
+ OBJ(bmpx_title) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.title);
+ }
+ OBJ(bmpx_artist) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.artist);
+ }
+ OBJ(bmpx_album) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.album);
+ }
+ OBJ(bmpx_uri) {
+ snprintf(p, p_max_size, "%s", cur->bmpx.uri);
+ }
+ OBJ(bmpx_track) {
+ snprintf(p, p_max_size, "%i", cur->bmpx.track);
+ }
+ OBJ(bmpx_bitrate) {
+ snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
+ }
+#endif
OBJ(top) {
if (obj->data.top.type == TOP_NAME
&& obj->data.top.num >= 0
#define CRIT_ERR(s, varargs...) \
{ fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
+#ifndef MIN
#define MIN(a,b) (a>b ? b : a)
+#endif
+#ifndef MAX
#define MAX(a,b) (a<b ? b : a)
+#endif
struct i8k_struct {
char *version;
};
#endif
+#ifdef BMPX
+struct bmpx_s {
+ char *title;
+ char *artist;
+ char *album;
+ char *uri;
+ int bitrate;
+ int track;
+};
+#endif
+
#ifdef TCP_PORT_MONITOR
#include "libtcp-portmon.h"
#define MIN_PORT_MONITORS_DEFAULT 16
#ifdef TCP_PORT_MONITOR
INFO_TCP_PORT_MONITOR = 22,
#endif
+#ifdef BMPX
+ INFO_BMPX = 23,
+#endif
};
struct mpd_s mpd;
mpd_Connection *conn;
#endif
+#ifdef BMPX
+ struct bmpx_s bmpx;
+#endif
struct process *cpu[10];
struct process *memu[10];
struct process *first_process;