{
obj->data.cpu_index=atoi(&arg[0]);
}
+ obj->a = 1;
END OBJ(freq_g, 0)
get_cpu_count();
if (!arg
{
obj->data.cpu_index=atoi(&arg[0]);
}
+ obj->a = 1;
END OBJ(voltage_mv, 0)
get_cpu_count();
if (!arg
|| (unsigned int)atoi(&arg[0])>info.cpu_count)
{
obj->data.cpu_index=1;
- ERR("voltage_mv: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
+// ERR("voltage_mv: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
}
else
{
obj->data.cpu_index=atoi(&arg[0]);
}
+ obj->a = 1;
END OBJ(voltage_v, 0)
get_cpu_count();
if (!arg
|| (unsigned int)atoi(&arg[0])>info.cpu_count)
{
obj->data.cpu_index=1;
- ERR("voltage_v: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
+// ERR("voltage_v: Invalid CPU number or you don't have that many CPUs! Displaying voltage for CPU 1.");
}
else
{
obj->data.cpu_index=atoi(&arg[0]);
}
+ obj->a = 1;
#else
END OBJ(freq, 0);
END OBJ(freq_g, 0);
i)+ 40) * 9.0 / 5 - 40));
}
OBJ(freq) {
- get_freq(p, p_max_size, "%.0f", 1, obj->data.cpu_index); /* pk */
+ if (obj->a) {
+ obj->a = get_freq(p, p_max_size, "%.0f", 1, obj->data.cpu_index); /* pk */
+ }
}
OBJ(freq_g) {
- get_freq(p, p_max_size, "%'.2f", 1000, obj->data.cpu_index); /* pk */
+ if (obj->a) {
+ obj->a = get_freq(p, p_max_size, "%'.2f", 1000, obj->data.cpu_index); /* pk */
+ }
}
OBJ(voltage_mv) {
- get_voltage(p, p_max_size, "%.0f", 1, obj->data.cpu_index); /* ptarjan */
+ if (obj->a) {
+ obj->a = get_voltage(p, p_max_size, "%.0f", 1, obj->data.cpu_index); /* ptarjan */
+ }
}
OBJ(voltage_v) {
- get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.cpu_index); /* ptarjan */
+ if (obj->a) {
+ obj->a = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.cpu_index); /* ptarjan */
+ }
}
OBJ(freq_dyn) {
void update_total_processes(void);
void update_running_processes(void);
void update_i8k(void);
-void get_freq( char *, size_t, char *, int, unsigned int ); /* pk */
+char get_freq( char *, size_t, char *, int, unsigned int ); /* pk */
void get_freq_dynamic( char *, size_t, char *, int ); /* pk */
-void get_voltage(char *, size_t, char *, int, unsigned int ); /* ptarjan */
+char get_voltage(char *, size_t, char *, int, unsigned int ); /* ptarjan */
void update_load_average();
int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
char *devtype);
#define CPUFREQ_POSTFIX "cpufreq/scaling_cur_freq"
/* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
-void get_freq( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
+char get_freq( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
{
FILE *f;
char frequency[32];
CPUFREQ_PREFIX, cpu, CPUFREQ_POSTFIX);
if ( !p_client_buffer || client_buffer_size <= 0 || !p_format || divisor <= 0 )
- return;
-
+ return 0;
+
f = fopen(current_freq_file, "r");
if (f) {
/* if there's a cpufreq /sys node, read the current frequency from this node;
}
fclose(f);
snprintf( p_client_buffer, client_buffer_size, p_format, (freq/1000)/divisor );
- return;
+ return 1;
}
cpu++;
f = fopen("/proc/cpuinfo", "r"); //open the CPU information file
- if (!f)
- return;
+ if (!f) {
+ perror("Conky: Failed to access '/proc/cpuinfo' at get_freq()");
+ return 0;
+ }
while (fgets(s, sizeof(s), f) != NULL){ //read the file
fclose(f);
snprintf( p_client_buffer, client_buffer_size, p_format, (float)freq/divisor );
- return;
+ return 1;
}
#define CPUFREQ_VOLTAGE "cpufreq/scaling_voltages"
/* return cpu voltage in mV (use divisor=1) or V (use divisor=1000) */
-void get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
+char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
{
/* /sys/devices/system/cpu/cpu0/cpufreq/scaling_voltages looks
something like this:
CPUFREQ_PREFIX, cpu, CPUFREQ_POSTFIX);
if ( !p_client_buffer || client_buffer_size <= 0 || !p_format || divisor <= 0 )
- return;
+ return 0;
/* read the current cpu frequency from the /sys node */
f = fopen(current_freq_file, "r");
freq = strtod(s, NULL);
}
fclose(f);
- }
- else
- {
- ERR("voltage: No %s.", current_freq_file);
- fclose(f);
- return;
+ } else {
+ fprintf(stderr, "Conky: Failed to access '%s' at ", current_freq_file);
+ perror("get_voltage()");
+ if (f) {
+ fclose(f);
+ }
+ return 0;
}
snprintf(current_freq_file, 127, "%s/cpu%d/%s",
/* use the current cpu frequency to find the corresponding voltage */
f = fopen(current_freq_file, "r");
- if (f)
- {
- while (!feof(f))
- {
- char line[256];
- if (fgets(line, 255, f) == NULL) break;
- sscanf(line, "%d %d", &freq_comp, &voltage);
- if(freq_comp == freq) break;
- }
- fclose(f);
- }
- else
- {
- ERR("voltage: No %s.", current_freq_file);
- fclose(f);
- return;
+ if (f) {
+ while (!feof(f)) {
+ char line[256];
+ if (fgets(line, 255, f) == NULL) break;
+ sscanf(line, "%d %d", &freq_comp, &voltage);
+ if(freq_comp == freq) break;
+ }
+ fclose(f);
+ } else {
+ fprintf(stderr, "Conky: Failed to access '%s' at ", current_freq_file);
+ perror("get_voltage()");
+ if (f) {
+ fclose(f);
+ }
+ return 0;
}
-
snprintf( p_client_buffer, client_buffer_size, p_format, (float)voltage/divisor );
- return;
+ return 1;
}