# $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
* Clarifying licensing
Print text to stdout.
- post_21_kernel
- Set to yes if you have Linux kernel 2.6.22 or newer
-
-
pad_percents
Pad percentages to this many decimals (0 = no padding)
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)
Displays the number of unseen messages in your global POP3 inbox
by default. You can define individual POP3 inboxes seperately by
</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>
<term><command><option>pad_percents</option></command></term>
<listitem>
Pad percentages to this many decimals (0 = no padding)
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
\fB\*(T<\fBpad_percents\fR\*(T>\fR
Pad percentages to this many decimals (0 = no padding)
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
\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.
</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>
<term>
<command><option>pop3_unseen</option></command>
<option>(args)</option>
exit(0);
}
-#if defined(__linux__)
-int post_21_kernel;
-#endif /* __linux__ */
-
#ifdef X11
/*
OBJ_mixerrbar,
OBJ_new_mails,
OBJ_nodename,
+ OBJ_platform,
OBJ_pre_exec,
OBJ_processes,
OBJ_running_processes,
int arg;
char devtype[256];
char type[64];
- } i2c; /* 2 */
+ } i2c, platform; /* 2 */
struct {
int pos;
case OBJ_i2c:
close(objs[i].data.i2c.fd);
break;
+ case OBJ_platform:
+ close(objs[i].data.platform.fd);
+ break;
#endif /* !__OpenBSD__ */
case OBJ_time:
free(objs[i].data.s);
obj->data.pair.b = b;
#ifndef __OpenBSD__
- END OBJ(i2c, INFO_I2C) char buf1[64], buf2[64];
+ END OBJ(i2c, INFO_I2C)
+ char buf1[64], buf2[64];
int n;
if (!arg) {
}
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 */
+ /* if scanf couldn't read three values, read type and num and use default device */
sscanf(arg, "%63s %d", buf2, &n);
obj->data.i2c.fd =
- open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg,
- obj->data.i2c.devtype);
+ open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg, obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63);
} else {
obj->data.i2c.fd =
- open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg,
- obj->data.i2c.devtype);
+ open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg, obj->data.i2c.devtype);
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__ */
END OBJ(top, INFO_TOP)
OBJ(i2c) {
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.devtype,
obj->data.i2c.type);
else
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__ */
OBJ(alignr) {
new_alignr(p, obj->data.i);
info.xmms2.status = NULL;
#endif
use_spacer = 0;
-#if defined(__linux__)
- post_21_kernel = 0;
-#endif /* __linux__ */
#ifdef X11
out_to_console = 0;
#else
CONF("draw_outline") {
draw_outline = string_to_bool(value);
}
-#if defined(__linux__)
- CONF("post_21_kernel") {
- post_21_kernel = string_to_bool(value);
- }
-#endif /* __linux__ */
#endif /* X11 */
CONF("out_to_console") {
out_to_console = string_to_bool(value);
INFO_DISKIO = 17,
INFO_I8K = 18,
#ifdef TCP_PORT_MONITOR
- INFO_TCP_PORT_MONITOR = 19,
+ INFO_TCP_PORT_MONITOR = 19,
#endif
#ifdef AUDACIOUS
INFO_AUDACIOUS = 20,
#ifdef RSS
INFO_RSS = 24,
#endif
+ INFO_PLATFORM = 25
};
void get_freq_dynamic( char *, size_t, char *, int );
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);
-double get_i2c_info(int *fd, int arg, char *devtype, char *type);
+
+int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype);
+#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_fan( char *, size_t );
void free_rss_info();
#endif /* RSS */
-#if defined(__linux__)
-extern int post_21_kernel;
-#endif /* __linux__ */
-
/* in linux.c */
#endif
}
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);
}
}
int
-open_i2c_sensor(const char *dev, const char *type, int n, int *div,
- char *devtype)
+open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
{
return (0);
}
}
}
-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 buf[256];
int fd;
/* if i2c device is NULL or *, get first */
if (dev == NULL || strcmp(dev, "*") == 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;
dev = buf;
}
type = "in";
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 {
- 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);
/* test if *_div file exist, open it and use it as divisor */
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);
} 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);
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;
}
-double get_i2c_info(int *fd, int div, char *devtype)
+double get_sysbus_info(int *fd, int div, char *devtype)
{
return -1;
}
}
int
-open_i2c_sensor(const char *dev, const char *type, int n, int *div,
- char *devtype)
+open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
{
return -1;
}