mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Use the internal process list for if_running on Linux
This commit is contained in:
parent
98e6f41bfa
commit
c6a5a060cf
@ -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)
|
||||
|
||||
|
10
src/conky.c
10
src/conky.c
@ -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;
|
||||
}
|
||||
}
|
||||
|
12
src/top.c
12
src/top.c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user