mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-23 19:39:06 +00:00
some small fixes for mpd stuff
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@935 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
2fcd64d59e
commit
12baf6c0b4
@ -4,7 +4,7 @@ dnl major, minor and micro version macros.
|
||||
m4_define([conky_version_major], [1])
|
||||
m4_define([conky_version_minor], [4])
|
||||
m4_define([conky_version_micro], [7])
|
||||
m4_define([conky_version_tag], [svn]) dnl [] for releases
|
||||
m4_define([conky_version_tag], []) dnl [] for releases
|
||||
m4_define([conky_version_revision],[r@REVISION@])
|
||||
m4_define([conky_version],
|
||||
[conky_version_major().conky_version_minor().conky_version_micro()ifelse(
|
||||
|
@ -233,7 +233,12 @@ void update_stuff()
|
||||
#ifdef MPD
|
||||
if (NEED(INFO_MPD)) {
|
||||
if (!mpd_timed_thread) {
|
||||
clear_mpd_stats(&info);
|
||||
mpd_timed_thread = timed_thread_create((void*)update_mpd, (void*) NULL, update_interval * 1000000);
|
||||
if (!mpd_timed_thread) {
|
||||
ERR("Failed to create MPD thread");
|
||||
}
|
||||
timed_thread_register(mpd_timed_thread, &mpd_timed_thread);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
34
src/conky.c
34
src/conky.c
@ -3140,13 +3140,15 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
OBJ(mpd_artist, INFO_MPD) END
|
||||
OBJ(mpd_title, INFO_MPD)
|
||||
{
|
||||
if (arg)
|
||||
{
|
||||
sscanf (arg, "%d", &info.mpd.max_title_len);
|
||||
if (info.mpd.max_title_len > 0)
|
||||
info.mpd.max_title_len++;
|
||||
else
|
||||
CRIT_ERR ("mpd_title: invalid length argument");
|
||||
if (arg) {
|
||||
sscanf (arg, "%d", &info.mpd.max_title_len);
|
||||
if (info.mpd.max_title_len > 0) {
|
||||
info.mpd.max_title_len++;
|
||||
} else {
|
||||
CRIT_ERR ("mpd_title: invalid length argument");
|
||||
}
|
||||
} else {
|
||||
info.mpd.max_title_len = 0;
|
||||
}
|
||||
}
|
||||
END OBJ(mpd_random, INFO_MPD)
|
||||
@ -3192,13 +3194,15 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
OBJ(audacious_status, INFO_AUDACIOUS) END
|
||||
OBJ(audacious_title, INFO_AUDACIOUS)
|
||||
{
|
||||
if (arg)
|
||||
{
|
||||
sscanf (arg, "%d", &info.audacious.max_title_len);
|
||||
if (info.audacious.max_title_len > 0)
|
||||
if (arg) {
|
||||
sscanf (arg, "%d", &info.audacious.max_title_len);
|
||||
if (info.audacious.max_title_len > 0) {
|
||||
info.audacious.max_title_len++;
|
||||
} else {
|
||||
CRIT_ERR ("audacious_title: invalid length argument");
|
||||
}
|
||||
} else {
|
||||
info.audacious.max_title_len++;
|
||||
else
|
||||
CRIT_ERR ("audacious_title: invalid length argument");
|
||||
}
|
||||
}
|
||||
END
|
||||
@ -4967,7 +4971,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
||||
255.0f));
|
||||
}
|
||||
OBJ(mpd_smart) {
|
||||
if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.title) < 2) {
|
||||
if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.artist) < 2) {
|
||||
snprintf(p, p_max_size, "%s", cur->mpd.file);
|
||||
} else {
|
||||
snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title);
|
||||
@ -7428,7 +7432,7 @@ int main(int argc, char **argv)
|
||||
struct sigaction act, oact;
|
||||
|
||||
g_signal_pending=0;
|
||||
memset(&info, 0, sizeof(info) );
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
tcp_port_monitor_args.max_port_monitor_connections = MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
|
||||
|
@ -619,6 +619,7 @@ char *get_apm_battery_time(void);
|
||||
|
||||
/* in mpd.c */
|
||||
#ifdef MPD
|
||||
extern void clear_mpd_stats(struct information *current_info);
|
||||
void *update_mpd(void);
|
||||
extern timed_thread *mpd_timed_thread;
|
||||
#endif /* MPD */
|
||||
|
22
src/mpd.c
22
src/mpd.c
@ -33,7 +33,7 @@
|
||||
|
||||
timed_thread *mpd_timed_thread = NULL;
|
||||
|
||||
static void clear_mpd_stats(struct information *current_info)
|
||||
void clear_mpd_stats(struct information *current_info)
|
||||
{
|
||||
if (current_info->mpd.artist == NULL)
|
||||
current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE);
|
||||
@ -90,8 +90,7 @@ void *update_mpd(void)
|
||||
current_info->conn = 0;
|
||||
|
||||
strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
|
||||
if (timed_thread_test(mpd_timed_thread))
|
||||
timed_thread_exit(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -109,8 +108,7 @@ void *update_mpd(void)
|
||||
|
||||
strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
|
||||
timed_thread_unlock(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread))
|
||||
timed_thread_exit(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -161,8 +159,7 @@ void *update_mpd(void)
|
||||
mpd_closeConnection(current_info->conn);
|
||||
current_info->conn = 0;
|
||||
timed_thread_unlock(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread))
|
||||
timed_thread_exit(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -226,8 +223,7 @@ void *update_mpd(void)
|
||||
//fprintf(stderr, "%s\n", current_info->conn->errorStr);
|
||||
mpd_closeConnection(current_info->conn);
|
||||
current_info->conn = 0;
|
||||
if (timed_thread_test(mpd_timed_thread))
|
||||
timed_thread_exit(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -236,8 +232,7 @@ void *update_mpd(void)
|
||||
//fprintf(stderr, "%s\n", current_info->conn->errorStr);
|
||||
mpd_closeConnection(current_info->conn);
|
||||
current_info->conn = 0;
|
||||
if (timed_thread_test(mpd_timed_thread))
|
||||
timed_thread_exit(mpd_timed_thread);
|
||||
if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
}
|
||||
mpd_freeStatus(status);
|
||||
@ -245,9 +240,8 @@ void *update_mpd(void)
|
||||
mpd_closeConnection(current_info->conn);
|
||||
current_info->conn = 0;
|
||||
}
|
||||
if (timed_thread_test(mpd_timed_thread))
|
||||
timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
|
||||
continue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user