1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

* Added var $platform which is similar to $i2c and accommodates the conversion

of many devices from /sys/bus/i2c/devices to /sys/bus/platform/devices.
* Removed config item post_21_kernel since it forced all i2c device lookups
    to go to /sys/bus/platform/devices and some people may need a mix of both
    i2c and platform devices.



git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@917 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2007-08-13 00:28:48 +00:00
parent dc676df556
commit 33943bda7c
10 changed files with 101 additions and 63 deletions

View File

@ -1,5 +1,12 @@
# $Id$ # $Id$
2007-08-12
* Added var $platform which is similar to $i2c and accommodates the conversion
of many devices from /sys/bus/i2c/devices to /sys/bus/platform/devices.
* Removed config item post_21_kernel since it forced all i2c device lookups
to go to /sys/bus/platform/devices and some people may need a mix of both
i2c and platform devices.
2007-08-10 2007-08-10
* Clarifying licensing * Clarifying licensing

12
README
View File

@ -345,10 +345,6 @@ CONFIGURATION SETTINGS
Print text to stdout. Print text to stdout.
post_21_kernel
Set to yes if you have Linux kernel 2.6.22 or newer
pad_percents pad_percents
Pad percentages to this many decimals (0 = no padding) Pad percentages to this many decimals (0 = no padding)
@ -1047,6 +1043,14 @@ VARIABLES
discharging. discharging.
platform (dev) type n
Platform sensor from sysfs (Linux 2.6). dev may be omitted if
you have only one platform device. type is either in (or vol)
meaning voltage, fan meaning fan or temp/tempf (first in C, sec-
ond in F) meaning temperature. n is number of the sensor. See
/sys/bus/platform/devices/ on your local computer.
pop3_unseen (args) pop3_unseen (args)
Displays the number of unseen messages in your global POP3 inbox Displays the number of unseen messages in your global POP3 inbox
by default. You can define individual POP3 inboxes seperately by by default. You can define individual POP3 inboxes seperately by

View File

@ -357,13 +357,6 @@
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><command><option>post_21_kernel</option></command>
</term>
<listitem>
Set to yes if you have Linux kernel 2.6.22 or newer
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><command><option>pad_percents</option></command></term> <term><command><option>pad_percents</option></command></term>
<listitem> <listitem>

View File

@ -336,10 +336,6 @@ of window can be useful for certain situations.
\fB\*(T<\fBout_to_console\fR\*(T>\fR \fB\*(T<\fBout_to_console\fR\*(T>\fR
Print text to stdout. Print text to stdout.
.TP
\fB\*(T<\fBpost_21_kernel\fR\*(T>\fR
Set to yes if you have Linux kernel 2.6.22 or newer
.TP .TP
\fB\*(T<\fBpad_percents\fR\*(T>\fR \fB\*(T<\fBpad_percents\fR\*(T>\fR
Pad percentages to this many decimals (0 = no padding) Pad percentages to this many decimals (0 = no padding)
@ -972,6 +968,12 @@ rate. Nothing is displayed, if battery is
absent or if it's present but fully charged absent or if it's present but fully charged
and not discharging. and not discharging.
.TP
\fB\*(T<\fBplatform\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T>
Platform sensor from sysfs (Linux 2.6). dev may be omitted if you have only one platform device. type is
either in (or vol) meaning voltage, fan meaning fan or temp/tempf (first in C, second in F) meaning temperature. n is number
of the sensor. See /sys/bus/platform/devices/ on your local computer.
.TP .TP
\fB\*(T<\fBpop3_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T> \fB\*(T<\fBpop3_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
Displays the number of unseen messages in your global POP3 inbox by default. You can define individual POP3 inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 110, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts. Displays the number of unseen messages in your global POP3 inbox by default. You can define individual POP3 inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 110, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.

View File

@ -1339,6 +1339,18 @@
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command><option>platform</option></command>
<option>(dev) type n</option>
</term>
<listitem>
Platform sensor from sysfs (Linux 2.6). dev may be omitted if you have only one platform device. type is
either in (or vol) meaning voltage, fan meaning fan or temp/tempf (first in C, second in F) meaning temperature. n is number
of the sensor. See /sys/bus/platform/devices/ on your local computer.
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command><option>pop3_unseen</option></command> <command><option>pop3_unseen</option></command>

View File

@ -124,10 +124,6 @@ static void print_version()
exit(0); exit(0);
} }
#if defined(__linux__)
int post_21_kernel;
#endif /* __linux__ */
#ifdef X11 #ifdef X11
/* /*
@ -1060,6 +1056,7 @@ enum text_object_type {
OBJ_mixerrbar, OBJ_mixerrbar,
OBJ_new_mails, OBJ_new_mails,
OBJ_nodename, OBJ_nodename,
OBJ_platform,
OBJ_pre_exec, OBJ_pre_exec,
OBJ_processes, OBJ_processes,
OBJ_running_processes, OBJ_running_processes,
@ -1229,7 +1226,7 @@ struct text_object {
int arg; int arg;
char devtype[256]; char devtype[256];
char type[64]; char type[64];
} i2c; /* 2 */ } i2c, platform; /* 2 */
struct { struct {
int pos; int pos;
@ -1816,6 +1813,9 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
case OBJ_i2c: case OBJ_i2c:
close(objs[i].data.i2c.fd); close(objs[i].data.i2c.fd);
break; break;
case OBJ_platform:
close(objs[i].data.platform.fd);
break;
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
case OBJ_time: case OBJ_time:
free(objs[i].data.s); free(objs[i].data.s);
@ -2596,7 +2596,8 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
obj->data.pair.b = b; obj->data.pair.b = b;
#ifndef __OpenBSD__ #ifndef __OpenBSD__
END OBJ(i2c, INFO_I2C) char buf1[64], buf2[64]; END OBJ(i2c, INFO_I2C)
char buf1[64], buf2[64];
int n; int n;
if (!arg) { if (!arg) {
@ -2607,19 +2608,38 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
} }
if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) { if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
/* if scanf couldn't read three values, read type and num and use /* if scanf couldn't read three values, read type and num and use default device */
* default device */
sscanf(arg, "%63s %d", buf2, &n); sscanf(arg, "%63s %d", buf2, &n);
obj->data.i2c.fd = obj->data.i2c.fd =
open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg, open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg, obj->data.i2c.devtype);
obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63); strncpy(obj->data.i2c.type, buf2, 63);
} else { } else {
obj->data.i2c.fd = obj->data.i2c.fd =
open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg, open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg, obj->data.i2c.devtype);
obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63); strncpy(obj->data.i2c.type, buf2, 63);
} }
END OBJ(i2c, INFO_PLATFORM)
char buf1[64], buf2[64];
int n;
if (!arg) {
ERR("platform needs arguments");
obj->type = OBJ_text;
return NULL;
}
if (sscanf(arg, "%63s %63s %d", buf1, buf2, &n) != 3) {
/* if scanf couldn't read three values, read type and num and use default device */
sscanf(arg, "%63s %d", buf2, &n);
obj->data.platform.fd =
open_platform_sensor(0, buf2, n, &obj->data.platform.arg, obj->data.platform.devtype);
strncpy(obj->data.platform.type, buf2, 63);
} else {
obj->data.platform.fd =
open_platform_sensor(buf1, buf2, n, &obj->data.platform.arg, obj->data.platform.devtype);
strncpy(obj->data.platform.type, buf2, 63);
}
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
END OBJ(top, INFO_TOP) END OBJ(top, INFO_TOP)
@ -4471,7 +4491,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
OBJ(i2c) { OBJ(i2c) {
double r; double r;
r = get_i2c_info(&obj->data.i2c.fd, r = get_sysbus_info(&obj->data.i2c.fd,
obj->data.i2c.arg, obj->data.i2c.arg,
obj->data.i2c.devtype, obj->data.i2c.devtype,
obj->data.i2c.type); obj->data.i2c.type);
@ -4481,6 +4501,19 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
else else
snprintf(p, p_max_size, "%.1f", r); snprintf(p, p_max_size, "%.1f", r);
} }
OBJ(platform) {
double r;
r = get_sysbus_info(&obj->data.platform.fd,
obj->data.platform.arg,
obj->data.platform.devtype,
obj->data.platform.type);
if (r >= 100.0 || r == 0)
snprintf(p, p_max_size, "%d", (int) r);
else
snprintf(p, p_max_size, "%.1f", r);
}
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
OBJ(alignr) { OBJ(alignr) {
new_alignr(p, obj->data.i); new_alignr(p, obj->data.i);
@ -6711,9 +6744,6 @@ static void set_default_configurations(void)
info.xmms2.status = NULL; info.xmms2.status = NULL;
#endif #endif
use_spacer = 0; use_spacer = 0;
#if defined(__linux__)
post_21_kernel = 0;
#endif /* __linux__ */
#ifdef X11 #ifdef X11
out_to_console = 0; out_to_console = 0;
#else #else
@ -7046,11 +7076,6 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
CONF("draw_outline") { CONF("draw_outline") {
draw_outline = string_to_bool(value); draw_outline = string_to_bool(value);
} }
#if defined(__linux__)
CONF("post_21_kernel") {
post_21_kernel = string_to_bool(value);
}
#endif /* __linux__ */
#endif /* X11 */ #endif /* X11 */
CONF("out_to_console") { CONF("out_to_console") {
out_to_console = string_to_bool(value); out_to_console = string_to_bool(value);

View File

@ -262,7 +262,7 @@ enum {
INFO_DISKIO = 17, INFO_DISKIO = 17,
INFO_I8K = 18, INFO_I8K = 18,
#ifdef TCP_PORT_MONITOR #ifdef TCP_PORT_MONITOR
INFO_TCP_PORT_MONITOR = 19, INFO_TCP_PORT_MONITOR = 19,
#endif #endif
#ifdef AUDACIOUS #ifdef AUDACIOUS
INFO_AUDACIOUS = 20, INFO_AUDACIOUS = 20,
@ -277,6 +277,7 @@ enum {
#ifdef RSS #ifdef RSS
INFO_RSS = 24, INFO_RSS = 24,
#endif #endif
INFO_PLATFORM = 25
}; };
@ -503,9 +504,15 @@ char get_freq( char *, size_t, char *, int, unsigned int );
void get_freq_dynamic( char *, size_t, char *, int ); void get_freq_dynamic( char *, size_t, char *, int );
char 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(); void update_load_average();
int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
char *devtype); int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype);
double get_i2c_info(int *fd, int arg, char *devtype, char *type); #define open_i2c_sensor(dev,type,n,div,devtype) \
open_sysbus_sensor("/sys/bus/i2c/devices/",dev,type,n,div,devtype)
#define open_platform_sensor(dev,type,n,div,devtype) \
open_sysbus_sensor("/sys/bus/platform/devices/",dev,type,n,div,devtype)
double get_sysbus_info(int *fd, int arg, char *devtype, char *type);
void get_adt746x_cpu( char *, size_t ); void get_adt746x_cpu( char *, size_t );
void get_adt746x_fan( char *, size_t ); void get_adt746x_fan( char *, size_t );
@ -630,10 +637,6 @@ void init_rss_info();
void free_rss_info(); void free_rss_info();
#endif /* RSS */ #endif /* RSS */
#if defined(__linux__)
extern int post_21_kernel;
#endif /* __linux__ */
/* in linux.c */ /* in linux.c */
#endif #endif

View File

@ -352,7 +352,7 @@ update_cpu_usage()
} }
double double
get_i2c_info(int *fd, int arg, char *devtype, char *type) get_sysbus_info(int *fd, int arg, char *devtype, char *type)
{ {
return (0); return (0);
} }
@ -469,8 +469,7 @@ get_battery_perct_bar(const char *bar)
} }
int int
open_i2c_sensor(const char *dev, const char *type, int n, int *div, open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
char *devtype)
{ {
return (0); return (0);
} }

View File

@ -659,14 +659,8 @@ get_first_file_in_a_directory(const char *dir, char *s, int *rep)
} }
} }
int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *devtype) int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
{ {
char i2c_dir[64];
if (post_21_kernel) {
strncpy(i2c_dir, "/sys/bus/platform/devices/", 64);
} else {
strncpy(i2c_dir, "/sys/bus/i2c/devices/", 64);
}
char path[256]; char path[256];
char buf[256]; char buf[256];
int fd; int fd;
@ -675,7 +669,7 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *de
/* if i2c device is NULL or *, get first */ /* if i2c device is NULL or *, get first */
if (dev == NULL || strcmp(dev, "*") == 0) { if (dev == NULL || strcmp(dev, "*") == 0) {
static int rep = 0; static int rep = 0;
if (!get_first_file_in_a_directory(i2c_dir, buf, &rep)) if (!get_first_file_in_a_directory(dir, buf, &rep))
return -1; return -1;
dev = buf; dev = buf;
} }
@ -685,9 +679,9 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *de
type = "in"; type = "in";
if (strcmp(type, "tempf") == 0) { if (strcmp(type, "tempf") == 0) {
snprintf(path, 255, "%s%s/%s%d_input", i2c_dir, dev, "temp", n); snprintf(path, 255, "%s%s/%s%d_input", dir, dev, "temp", n);
} else { } else {
snprintf(path, 255, "%s%s/%s%d_input", i2c_dir, dev, type, n); snprintf(path, 255, "%s%s/%s%d_input", dir, dev, type, n);
} }
strncpy(devtype, path, 255); strncpy(devtype, path, 255);
@ -708,10 +702,10 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *de
/* test if *_div file exist, open it and use it as divisor */ /* test if *_div file exist, open it and use it as divisor */
if (strcmp(type, "tempf") == 0) { if (strcmp(type, "tempf") == 0) {
snprintf(path, 255, "%s%s/%s%d_div", i2c_dir, "one", "two", snprintf(path, 255, "%s%s/%s%d_div", dir, "one", "two",
n); n);
} else { } else {
snprintf(path, 255, "%s%s/%s%d_div", i2c_dir, dev, type, n); snprintf(path, 255, "%s%s/%s%d_div", dir, dev, type, n);
} }
divfd = open(path, O_RDONLY); divfd = open(path, O_RDONLY);
@ -731,7 +725,7 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *de
return fd; return fd;
} }
double get_i2c_info(int *fd, int div, char *devtype, char *type) double get_sysbus_info(int *fd, int div, char *devtype, char *type)
{ {
int val = 0; int val = 0;

View File

@ -339,7 +339,7 @@ void update_cpu_usage()
} }
double get_i2c_info(int *fd, int div, char *devtype) double get_sysbus_info(int *fd, int div, char *devtype)
{ {
return -1; return -1;
} }
@ -364,8 +364,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
} }
int int
open_i2c_sensor(const char *dev, const char *type, int n, int *div, open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
char *devtype)
{ {
return -1; return -1;
} }