mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
audacious: convert to callbacks.print
This commit is contained in:
parent
974d28a667
commit
6371551153
@ -254,3 +254,44 @@ void *audacious_thread_func(void *pvoid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_audacious_title(struct text_object *obj, char *p, int p_max_size)
|
||||||
|
{
|
||||||
|
snprintf(p, info.audacious.max_title_len > 0
|
||||||
|
? info.audacious.max_title_len : p_max_size, "%s",
|
||||||
|
info.audacious.items[AUDACIOUS_TITLE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_audacious_bar(struct text_object *obj, char *p, int p_max_size)
|
||||||
|
{
|
||||||
|
double progress;
|
||||||
|
|
||||||
|
if (!p_max_size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
progress =
|
||||||
|
atof(info.audacious.items[AUDACIOUS_POSITION_SECONDS]) /
|
||||||
|
atof(info.audacious.items[AUDACIOUS_LENGTH_SECONDS]);
|
||||||
|
new_bar(obj, p, p_max_size, (int) (progress * 255.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define AUDACIOUS_PRINT_GENERATOR(name, idx) \
|
||||||
|
void print_audacious_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||||
|
{ \
|
||||||
|
snprintf(p, p_max_size, "%s", info.audacious.items[AUDACIOUS_##idx]); \
|
||||||
|
}
|
||||||
|
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(status, STATUS)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(length, LENGTH)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(length_seconds, LENGTH_SECONDS)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(position, POSITION)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(position_seconds, POSITION_SECONDS)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(bitrate, BITRATE)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(frequency, FREQUENCY)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(channels, CHANNELS)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(filename, FILENAME)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(playlist_length, PLAYLIST_LENGTH)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(playlist_position, PLAYLIST_POSITION)
|
||||||
|
AUDACIOUS_PRINT_GENERATOR(main_volume, MAIN_VOLUME)
|
||||||
|
|
||||||
|
#undef AUDACIOUS_PRINT_GENERATOR
|
||||||
|
@ -65,4 +65,19 @@ void update_audacious(void);
|
|||||||
/* Thread functions */
|
/* Thread functions */
|
||||||
void *audacious_thread_func(void *);
|
void *audacious_thread_func(void *);
|
||||||
|
|
||||||
|
void print_audacious_status(struct text_object *, char *, int);
|
||||||
|
void print_audacious_title(struct text_object *, char *, int);
|
||||||
|
void print_audacious_length(struct text_object *, char *, int);
|
||||||
|
void print_audacious_length_seconds(struct text_object *, char *, int);
|
||||||
|
void print_audacious_position(struct text_object *, char *, int);
|
||||||
|
void print_audacious_position_seconds(struct text_object *, char *, int);
|
||||||
|
void print_audacious_bitrate(struct text_object *, char *, int);
|
||||||
|
void print_audacious_frequency(struct text_object *, char *, int);
|
||||||
|
void print_audacious_channels(struct text_object *, char *, int);
|
||||||
|
void print_audacious_filename(struct text_object *, char *, int);
|
||||||
|
void print_audacious_playlist_length(struct text_object *, char *, int);
|
||||||
|
void print_audacious_playlist_position(struct text_object *, char *, int);
|
||||||
|
void print_audacious_main_volume(struct text_object *, char *, int);
|
||||||
|
void print_audacious_bar(struct text_object *, char *, int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
63
src/conky.c
63
src/conky.c
@ -1635,69 +1635,6 @@ void generate_text_internal(char *p, int p_max_size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* XMMS */
|
#endif /* XMMS */
|
||||||
#ifdef AUDACIOUS
|
|
||||||
OBJ(audacious_status) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_STATUS]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_title) {
|
|
||||||
snprintf(p, cur->audacious.max_title_len > 0
|
|
||||||
? cur->audacious.max_title_len : p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_TITLE]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_length) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_LENGTH]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_length_seconds) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_position) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_POSITION]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_position_seconds) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_POSITION_SECONDS]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_bitrate) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_BITRATE]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_frequency) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_FREQUENCY]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_channels) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_CHANNELS]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_filename) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_FILENAME]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_playlist_length) {
|
|
||||||
snprintf(p, p_max_size, "%s",
|
|
||||||
cur->audacious.items[AUDACIOUS_PLAYLIST_LENGTH]);
|
|
||||||
}
|
|
||||||
OBJ(audacious_playlist_position) {
|
|
||||||
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;
|
|
||||||
|
|
||||||
progress =
|
|
||||||
atof(cur->audacious.items[AUDACIOUS_POSITION_SECONDS]) /
|
|
||||||
atof(cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
|
|
||||||
new_bar(obj, p, p_max_size, (int) (progress * 255.0f));
|
|
||||||
}
|
|
||||||
#endif /* AUDACIOUS */
|
|
||||||
|
|
||||||
#ifdef BMPX
|
#ifdef BMPX
|
||||||
OBJ(bmpx_title) {
|
OBJ(bmpx_title) {
|
||||||
|
16
src/core.c
16
src/core.c
@ -1168,6 +1168,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
#endif
|
#endif
|
||||||
#ifdef AUDACIOUS
|
#ifdef AUDACIOUS
|
||||||
END OBJ(audacious_status, &update_audacious)
|
END OBJ(audacious_status, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_status;
|
||||||
END OBJ_ARG(audacious_title, &update_audacious, "audacious_title needs an argument")
|
END OBJ_ARG(audacious_title, &update_audacious, "audacious_title needs an argument")
|
||||||
sscanf(arg, "%d", &info.audacious.max_title_len);
|
sscanf(arg, "%d", &info.audacious.max_title_len);
|
||||||
if (info.audacious.max_title_len > 0) {
|
if (info.audacious.max_title_len > 0) {
|
||||||
@ -1175,20 +1176,33 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
} else {
|
} else {
|
||||||
CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
|
CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
|
||||||
}
|
}
|
||||||
|
obj->callbacks.print = &print_audacious_title;
|
||||||
END OBJ(audacious_length, &update_audacious)
|
END OBJ(audacious_length, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_length;
|
||||||
END OBJ(audacious_length_seconds, &update_audacious)
|
END OBJ(audacious_length_seconds, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_length_seconds;
|
||||||
END OBJ(audacious_position, &update_audacious)
|
END OBJ(audacious_position, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_position;
|
||||||
END OBJ(audacious_position_seconds, &update_audacious)
|
END OBJ(audacious_position_seconds, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_position_seconds;
|
||||||
END OBJ(audacious_bitrate, &update_audacious)
|
END OBJ(audacious_bitrate, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_bitrate;
|
||||||
END OBJ(audacious_frequency, &update_audacious)
|
END OBJ(audacious_frequency, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_frequency;
|
||||||
END OBJ(audacious_channels, &update_audacious)
|
END OBJ(audacious_channels, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_channels;
|
||||||
END OBJ(audacious_filename, &update_audacious)
|
END OBJ(audacious_filename, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_filename;
|
||||||
END OBJ(audacious_playlist_length, &update_audacious)
|
END OBJ(audacious_playlist_length, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_playlist_length;
|
||||||
END OBJ(audacious_playlist_position, &update_audacious)
|
END OBJ(audacious_playlist_position, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_playlist_position;
|
||||||
END OBJ(audacious_main_volume, &update_audacious)
|
END OBJ(audacious_main_volume, &update_audacious)
|
||||||
|
obj->callbacks.print = &print_audacious_main_volume;
|
||||||
END OBJ(audacious_bar, &update_audacious)
|
END OBJ(audacious_bar, &update_audacious)
|
||||||
scan_bar(obj, arg);
|
scan_bar(obj, arg);
|
||||||
#endif
|
obj->callbacks.print = &print_audacious_bar;
|
||||||
|
#endif /* AUDACIOUS */
|
||||||
#ifdef BMPX
|
#ifdef BMPX
|
||||||
END OBJ(bmpx_title, &update_bmpx)
|
END OBJ(bmpx_title, &update_bmpx)
|
||||||
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
|
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
|
||||||
|
Loading…
Reference in New Issue
Block a user