mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-24 11:55:43 +00:00
Add BMPx (http://beep-media-player.org/) support. Bugs and memleaks are here
for sure, will deal with it a bit later. git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@452 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
b52361ac9c
commit
5e91a7d617
1
AUTHORS
1
AUTHORS
@ -134,6 +134,7 @@ Rui Paulo <rpaulo at netbsd-pt dot org>
|
||||
|
||||
Roman Bogorodskiy <novel at clublife dot ru>
|
||||
FreeBSD support
|
||||
BMPx support
|
||||
|
||||
Szymon Boniecki
|
||||
Reads current LC_TIME
|
||||
|
@ -1,5 +1,8 @@
|
||||
# $Id$
|
||||
|
||||
2005-12-30
|
||||
* Added BMPx (http://beep-media-player.org/) support
|
||||
|
||||
2005-12-14
|
||||
* Fixed issues with execi stuff
|
||||
|
||||
|
17
configure.in
17
configure.in
@ -78,6 +78,23 @@ if test $dah = "yes"; then
|
||||
AC_DEFINE(PROC_UPTIME, 1, [Define if you want to use /proc/uptime for uptime])
|
||||
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
|
||||
|
@ -1,5 +1,9 @@
|
||||
bin_PROGRAMS = conky
|
||||
|
||||
if BUILD_BMPX
|
||||
bmpx = bmpx.c
|
||||
endif
|
||||
|
||||
if BUILD_SETI
|
||||
seti = seti.c
|
||||
endif
|
||||
@ -38,7 +42,7 @@ if BUILD_X11
|
||||
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
|
||||
|
||||
|
86
src/bmpx.c
Normal file
86
src/bmpx.c
Normal file
@ -0,0 +1,86 @@
|
||||
/** 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;
|
||||
}
|
||||
}
|
@ -226,6 +226,10 @@ void update_stuff()
|
||||
if (NEED(INFO_MPD))
|
||||
update_mpd();
|
||||
#endif
|
||||
#ifdef BMPX
|
||||
if (NEED(INFO_BMPX))
|
||||
update_bmpx();
|
||||
#endif
|
||||
|
||||
if (NEED(INFO_LOADAVG))
|
||||
update_load_average();
|
||||
|
50
src/conky.c
50
src/conky.c
@ -891,6 +891,14 @@ enum text_object_type {
|
||||
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
|
||||
@ -1067,6 +1075,14 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
|
||||
case OBJ_mpd_track:
|
||||
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:
|
||||
@ -1777,6 +1793,20 @@ int a = stippled_borders, b = 1;
|
||||
(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;
|
||||
@ -3031,6 +3061,26 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
||||
(int) (cur->mpd.progress *
|
||||
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
|
||||
|
21
src/conky.h
21
src/conky.h
@ -56,8 +56,12 @@ fprintf(stderr, "Conky: " s "\n", ##varargs)
|
||||
#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;
|
||||
@ -118,6 +122,17 @@ struct mpd_s {
|
||||
};
|
||||
#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
|
||||
@ -155,6 +170,9 @@ enum {
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
INFO_TCP_PORT_MONITOR = 22,
|
||||
#endif
|
||||
#ifdef BMPX
|
||||
INFO_BMPX = 23,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -197,6 +215,9 @@ struct information {
|
||||
#ifdef MPD
|
||||
struct mpd_s mpd;
|
||||
mpd_Connection *conn;
|
||||
#endif
|
||||
#ifdef BMPX
|
||||
struct bmpx_s bmpx;
|
||||
#endif
|
||||
struct process *cpu[10];
|
||||
struct process *memu[10];
|
||||
|
Loading…
Reference in New Issue
Block a user