mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-13 19:22:58 +00:00
add mpd_date function that shows date for current track (sf.net #3440445)
patch submitted by Andrey Tikhonov
This commit is contained in:
parent
6cce8e8e11
commit
be4854c6bb
@ -2481,6 +2481,15 @@
|
||||
<listitem>Bitrate of current song
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>mpd_date</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>Date of current song
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
|
@ -268,8 +268,8 @@ legacy_cb_handle *create_cb_handle(int (*fn)())
|
||||
}
|
||||
|
||||
/* construct_text_object() creates a new text_object */
|
||||
struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
line, void **ifblock_opaque, void *free_at_crash)
|
||||
struct text_object *construct_text_object(char *s, const char *arg,
|
||||
long line, void **ifblock_opaque, void *free_at_crash)
|
||||
{
|
||||
// struct text_object *obj = new_text_object();
|
||||
struct text_object *obj = new_text_object_internal();
|
||||
@ -1408,6 +1408,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
END OBJ(mpd_title, 0)
|
||||
mpd_set_maxlen(mpd_title);
|
||||
obj->callbacks.print = &print_mpd_title;
|
||||
END OBJ(mpd_date, 0)
|
||||
mpd_set_maxlen(mpd_date);
|
||||
obj->callbacks.print = &print_mpd_date;
|
||||
END OBJ(mpd_random, 0)
|
||||
obj->callbacks.print = &print_mpd_random;
|
||||
END OBJ(mpd_repeat, 0)
|
||||
|
20
src/mpd.cc
20
src/mpd.cc
@ -123,6 +123,7 @@ namespace {
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string date;
|
||||
std::string status;
|
||||
std::string random;
|
||||
std::string repeat;
|
||||
@ -162,7 +163,7 @@ namespace {
|
||||
mpd_Status *status;
|
||||
mpd_InfoEntity *entity;
|
||||
mpd_result mpd_info;
|
||||
|
||||
|
||||
do {
|
||||
if (!conn)
|
||||
conn = mpd_newConnection(mpd_host.get(*state).c_str(), mpd_port.get(*state), 10);
|
||||
@ -260,12 +261,15 @@ namespace {
|
||||
mpd_freeInfoEntity(entity);
|
||||
continue;
|
||||
}
|
||||
mpd_info.artist = song->artist;
|
||||
mpd_info.album = song->album;
|
||||
mpd_info.title = song->title;
|
||||
mpd_info.track = song->track;
|
||||
mpd_info.name = song->name;
|
||||
mpd_info.file = song->file;
|
||||
#define SETSTRING(a,b) \
|
||||
if (b) a=b; else a="";
|
||||
SETSTRING(mpd_info.artist, song->artist);
|
||||
SETSTRING(mpd_info.album, song->album);
|
||||
SETSTRING(mpd_info.title, song->title);
|
||||
SETSTRING(mpd_info.date, song->date);
|
||||
SETSTRING(mpd_info.track, song->track);
|
||||
SETSTRING(mpd_info.name, song->name);
|
||||
SETSTRING(mpd_info.file, song->file);
|
||||
if (entity != NULL) {
|
||||
mpd_freeInfoEntity(entity);
|
||||
entity = NULL;
|
||||
@ -293,6 +297,7 @@ namespace {
|
||||
conn = 0;
|
||||
} */
|
||||
} while (0);
|
||||
result = mpd_info; // don't forget to save results!
|
||||
}
|
||||
|
||||
mpd_result get_mpd()
|
||||
@ -394,6 +399,7 @@ void print_mpd_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||
MPD_PRINT_GENERATOR(title, "%s", .c_str())
|
||||
MPD_PRINT_GENERATOR(artist, "%s", .c_str())
|
||||
MPD_PRINT_GENERATOR(album, "%s", .c_str())
|
||||
MPD_PRINT_GENERATOR(date, "%s", .c_str())
|
||||
MPD_PRINT_GENERATOR(random, "%s", .c_str())
|
||||
MPD_PRINT_GENERATOR(repeat, "%s", .c_str())
|
||||
MPD_PRINT_GENERATOR(track, "%s", .c_str())
|
||||
|
@ -35,6 +35,7 @@ void print_mpd_smart(struct text_object *, char *, int);
|
||||
void print_mpd_title(struct text_object *, char *, int);
|
||||
void print_mpd_artist(struct text_object *, char *, int);
|
||||
void print_mpd_album(struct text_object *, char *, int);
|
||||
void print_mpd_date(struct text_object *, char *, int);
|
||||
void print_mpd_random(struct text_object *, char *, int);
|
||||
void print_mpd_repeat(struct text_object *, char *, int);
|
||||
void print_mpd_track(struct text_object *, char *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user