1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 20:44:56 +00:00

Merge branch 'lua-config'

This commit is contained in:
Nikolas Garofil 2010-11-23 18:56:58 +01:00
commit 7b128a9f16
3 changed files with 21 additions and 0 deletions

View File

@ -849,6 +849,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long
* nothing else than just that, using an ugly switch(). */
if (strncmp(s, "top", 3) == EQUAL) {
if (parse_top_args(s, arg, obj)) {
#ifdef __linux__
determine_longstat_file();
#endif
add_update_callback(&update_top);
} else {
free(obj);

View File

@ -661,6 +661,23 @@ void determine_longstat(char *buf)
}
}
void determine_longstat_file(void) {
#define MAX_PROCSTAT_LINELEN 255
FILE *stat_fp;
static int rep = 0;
char buf[MAX_PROCSTAT_LINELEN + 1];
if ( not (stat_fp = open_file("/proc/stat", &rep))) return;
while ( not feof(stat_fp)) {
if (fgets(buf, MAX_PROCSTAT_LINELEN, stat_fp) == NULL) break;
if (strncmp(buf, "cpu", 3) == 0) {
determine_longstat(buf);
break;
}
}
fclose(stat_fp);
}
void get_cpu_count(void)
{
FILE *stat_fp;

View File

@ -55,4 +55,5 @@ int update_stat(void);
void print_distribution(struct text_object *, char *, int);
void determine_longstat_file(void);
#endif /* _LINUX_H */