1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-28 13:00:45 +00:00

make top_cpu_separate a lua setting

This commit is contained in:
Pavel Labath 2010-03-07 13:29:30 +01:00
parent 357a505dc4
commit aa95dfdd5e
4 changed files with 9 additions and 16 deletions

View File

@ -373,7 +373,7 @@ static void *run_update_callback(void *data)
} }
} }
conky::simple_config_setting<bool> no_buffers("no_buffers", true, false); conky::simple_config_setting<bool> no_buffers("no_buffers", true, true);
void update_stuff(void) void update_stuff(void)
{ {

View File

@ -156,7 +156,6 @@ static conky::simple_config_setting<spacer_state> use_spacer("use_spacer", NO_SP
/* variables holding various config settings */ /* variables holding various config settings */
int short_units; int short_units;
int format_human_readable; int format_human_readable;
int cpu_separate;
int top_cpu, top_mem, top_time; int top_cpu, top_mem, top_time;
#ifdef BUILD_IOSTATS #ifdef BUILD_IOSTATS
int top_io; int top_io;
@ -2492,7 +2491,6 @@ static void set_default_configurations(void)
info.diskio_avg_samples = 2; info.diskio_avg_samples = 2;
info.memmax = 0; info.memmax = 0;
top_cpu = 0; top_cpu = 0;
cpu_separate = 0;
short_units = 0; short_units = 0;
format_human_readable = 1; format_human_readable = 1;
top_mem = 0; top_mem = 0;
@ -3117,9 +3115,6 @@ char load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
#endif /* __linux__ */ #endif /* __linux__ */
CONF("top_cpu_separate") {
cpu_separate = string_to_bool(value);
}
CONF("short_units") { CONF("short_units") {
short_units = string_to_bool(value); short_units = string_to_bool(value);
} }

View File

@ -271,9 +271,6 @@ extern int top_io;
#endif /* BUILD_IOSTATS */ #endif /* BUILD_IOSTATS */
extern int top_running; extern int top_running;
/* defined in conky.c, needed by top.c */
extern int cpu_separate;
/* struct that has all info to be shared between /* struct that has all info to be shared between
* instances of the same text object */ * instances of the same text object */
extern struct information info; extern struct information info;

View File

@ -32,6 +32,7 @@
#include "prioqueue.h" #include "prioqueue.h"
#include "top.h" #include "top.h"
#include "logging.h" #include "logging.h"
#include "setting.hh"
/* hash table size - always a power of 2 */ /* hash table size - always a power of 2 */
#define HTABSIZE 256 #define HTABSIZE 256
@ -40,6 +41,8 @@ static unsigned long g_time = 0;
static unsigned long long previous_total = 0; static unsigned long long previous_total = 0;
static struct process *first_process = 0; static struct process *first_process = 0;
static conky::simple_config_setting<bool> top_cpu_separate("top_cpu_separate", false, true);
/* a simple hash table to speed up find_process() */ /* a simple hash table to speed up find_process() */
struct proc_hash_entry { struct proc_hash_entry {
struct proc_hash_entry *next; struct proc_hash_entry *next;
@ -560,14 +563,12 @@ static unsigned long long calc_cpu_total(void)
inline static void calc_cpu_each(unsigned long long total) inline static void calc_cpu_each(unsigned long long total)
{ {
struct process *p = first_process; float mul = 100.0;
if(top_cpu_separate.get(*state))
mul *= info.cpu_count;
while (p) { for(struct process *p = first_process; p; p = p->next)
p->amount = 100.0 * (cpu_separate ? info.cpu_count : 1) * p->amount = mul * (p->user_time + p->kernel_time) / (float) total;
(p->user_time + p->kernel_time) / (float) total;
p = p->next;
}
} }
#ifdef BUILD_IOSTATS #ifdef BUILD_IOSTATS