1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

Use the internal process list for if_running on Linux

This commit is contained in:
Phil Sutter 2009-06-20 01:40:40 +02:00
parent 98e6f41bfa
commit c6a5a060cf
4 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,6 @@
2009-06-20
* Use the internal process list for if_running on Linux
2009-06-14
* Fix XMMS2 related crash (sf.net #2806111 and #2805310, thanks Lassi)

View File

@ -2100,12 +2100,18 @@ static struct text_object *construct_text_object(const char *s,
} else {
obj->data.ifblock.s = strndup(arg, text_buffer_size);
}
#ifdef __linux__
END OBJ_IF(if_running, INFO_TOP)
if (arg) {
obj->data.ifblock.s = strndup(arg, text_buffer_size);
#else
END OBJ_IF(if_running, 0)
if (arg) {
char buf[256];
snprintf(buf, 256, "pidof %s >/dev/null", arg);
obj->data.ifblock.s = strndup(buf, text_buffer_size);
#endif
} else {
ERR("if_running needs an argument");
obj->data.ifblock.s = 0;
@ -4796,7 +4802,11 @@ static void generate_text_internal(char *p, int p_max_size,
}
}
OBJ(if_running) {
#ifdef __linux__
if (!get_process_by_name(obj->data.ifblock.s)) {
#else
if ((obj->data.ifblock.s) && system(obj->data.ifblock.s)) {
#endif
DO_JUMP;
}
}

View File

@ -52,6 +52,18 @@ void free_all_processes(void)
first_process = NULL;
}
struct process *get_process_by_name(const char *name)
{
struct process *p = first_process;
while (p) {
if (!strcmp(p->name, name))
return p;
p = p->next;
}
return 0;
}
static struct process *find_process(pid_t pid)
{
struct process *p = first_process;

View File

@ -136,4 +136,7 @@ void process_find_top(struct process **, struct process **, struct process **
#endif
);
/* lookup a program by it's name */
struct process *get_process_by_name(const char *);
#endif /* _top_h_ */