mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 19:06:36 +00:00
parent
53973402b4
commit
aac26b549e
12
src/core.cc
12
src/core.cc
@ -747,15 +747,14 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
END OBJ(diskiograph_write, &update_diskio) parse_diskiograph_arg(obj, arg);
|
END OBJ(diskiograph_write, &update_diskio) parse_diskiograph_arg(obj, arg);
|
||||||
obj->callbacks.graphval = &diskiographval_write;
|
obj->callbacks.graphval = &diskiographval_write;
|
||||||
#endif /* BUILD_GUI */
|
#endif /* BUILD_GUI */
|
||||||
END OBJ(color, nullptr)
|
END OBJ(color, nullptr) if (false
|
||||||
if (false
|
|
||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
|| out_to_gui(*state)
|
|| out_to_gui(*state)
|
||||||
#endif /* BUILD_GUI */
|
#endif /* BUILD_GUI */
|
||||||
#ifdef BUILD_NCURSES
|
#ifdef BUILD_NCURSES
|
||||||
|| out_to_ncurses.get(*state)
|
|| out_to_ncurses.get(*state)
|
||||||
#endif /* BUILD_NCURSES */
|
#endif /* BUILD_NCURSES */
|
||||||
) {
|
) {
|
||||||
Colour c = arg != nullptr ? parse_color(arg) : default_color.get(*state);
|
Colour c = arg != nullptr ? parse_color(arg) : default_color.get(*state);
|
||||||
obj->data.l = c.to_argb32();
|
obj->data.l = c.to_argb32();
|
||||||
set_current_text_color(c);
|
set_current_text_color(c);
|
||||||
@ -1058,9 +1057,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
* nothing else than just that, using an ugly switch(). */
|
* nothing else than just that, using an ugly switch(). */
|
||||||
if (strncmp(s, "top", 3) == EQUAL) {
|
if (strncmp(s, "top", 3) == EQUAL) {
|
||||||
if (parse_top_args(s, arg, obj) != 0) {
|
if (parse_top_args(s, arg, obj) != 0) {
|
||||||
#ifdef __linux__
|
|
||||||
determine_longstat_file();
|
|
||||||
#endif
|
|
||||||
obj->cb_handle = create_cb_handle(update_top);
|
obj->cb_handle = create_cb_handle(update_top);
|
||||||
} else {
|
} else {
|
||||||
free(obj);
|
free(obj);
|
||||||
|
@ -903,6 +903,10 @@ void determine_longstat_file(void) {
|
|||||||
FILE *stat_fp;
|
FILE *stat_fp;
|
||||||
static int reported = 0;
|
static int reported = 0;
|
||||||
char buf[MAX_PROCSTAT_LINELEN + 1];
|
char buf[MAX_PROCSTAT_LINELEN + 1];
|
||||||
|
static int stat_initialized = 0;
|
||||||
|
|
||||||
|
/* only execute once */
|
||||||
|
if (stat_initialized) return;
|
||||||
|
|
||||||
if (!(stat_fp = open_file("/proc/stat", &reported))) return;
|
if (!(stat_fp = open_file("/proc/stat", &reported))) return;
|
||||||
while (!feof(stat_fp) &&
|
while (!feof(stat_fp) &&
|
||||||
@ -913,6 +917,7 @@ void determine_longstat_file(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(stat_fp);
|
fclose(stat_fp);
|
||||||
|
stat_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_cpu_count(void) {
|
void get_cpu_count(void) {
|
||||||
@ -1000,6 +1005,7 @@ int update_stat(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!stat_template) {
|
if (!stat_template) {
|
||||||
|
determine_longstat_file();
|
||||||
stat_template =
|
stat_template =
|
||||||
KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGSTAT : TMPL_SHORTSTAT;
|
KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGSTAT : TMPL_SHORTSTAT;
|
||||||
}
|
}
|
||||||
@ -1216,8 +1222,7 @@ static void get_dev_path(const char *dir, const char *dev, char *out_buf) {
|
|||||||
if (name_fd < 0) {
|
if (name_fd < 0) {
|
||||||
snprintf(path, 512, "%s%s/device/name", dir, namelist[i]->d_name);
|
snprintf(path, 512, "%s%s/device/name", dir, namelist[i]->d_name);
|
||||||
name_fd = open(path, O_RDONLY);
|
name_fd = open(path, O_RDONLY);
|
||||||
if (name_fd < 0)
|
if (name_fd < 0) continue;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
size = read(name_fd, name, strlen(dev));
|
size = read(name_fd, name, strlen(dev));
|
||||||
if (size < strlen(dev)) {
|
if (size < strlen(dev)) {
|
||||||
|
@ -58,8 +58,6 @@ int update_stat(void);
|
|||||||
|
|
||||||
void print_distribution(struct text_object *, char *, unsigned int);
|
void print_distribution(struct text_object *, char *, unsigned int);
|
||||||
|
|
||||||
void determine_longstat_file(void);
|
|
||||||
|
|
||||||
extern char e_iface[64];
|
extern char e_iface[64];
|
||||||
extern char interfaces_arr[MAX_NET_INTERFACES][64];
|
extern char interfaces_arr[MAX_NET_INTERFACES][64];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user