1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 21:49:07 +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$
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

12
README
View File

@ -345,10 +345,6 @@ CONFIGURATION SETTINGS
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)
@ -1047,6 +1043,14 @@ VARIABLES
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

View File

@ -357,13 +357,6 @@
<para></para></listitem>
</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>

View File

@ -336,10 +336,6 @@ of window can be useful for certain situations.
\fB\*(T<\fBout_to_console\fR\*(T>\fR
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)
@ -972,6 +968,12 @@ rate. Nothing is displayed, if battery is
absent or if it's present but fully charged
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.

View File

@ -1339,6 +1339,18 @@
<para></para></listitem>
</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>

View File

@ -124,10 +124,6 @@ static void print_version()
exit(0);
}
#if defined(__linux__)
int post_21_kernel;
#endif /* __linux__ */
#ifdef X11
/*
@ -1060,6 +1056,7 @@ enum text_object_type {
OBJ_mixerrbar,
OBJ_new_mails,
OBJ_nodename,
OBJ_platform,
OBJ_pre_exec,
OBJ_processes,
OBJ_running_processes,
@ -1229,7 +1226,7 @@ struct text_object {
int arg;
char devtype[256];
char type[64];
} i2c; /* 2 */
} i2c, platform; /* 2 */
struct {
int pos;
@ -1816,6 +1813,9 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
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);
@ -2596,7 +2596,8 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
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) {
@ -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 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)
@ -4471,7 +4491,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
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);
@ -4481,6 +4501,19 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
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);
@ -6711,9 +6744,6 @@ static void set_default_configurations(void)
info.xmms2.status = NULL;
#endif
use_spacer = 0;
#if defined(__linux__)
post_21_kernel = 0;
#endif /* __linux__ */
#ifdef X11
out_to_console = 0;
#else
@ -7046,11 +7076,6 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
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);

View File

@ -262,7 +262,7 @@ enum {
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,
@ -277,6 +277,7 @@ enum {
#ifdef RSS
INFO_RSS = 24,
#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 );
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 );
@ -630,10 +637,6 @@ void init_rss_info();
void free_rss_info();
#endif /* RSS */
#if defined(__linux__)
extern int post_21_kernel;
#endif /* __linux__ */
/* in linux.c */
#endif

View File

@ -352,7 +352,7 @@ update_cpu_usage()
}
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);
}
@ -469,8 +469,7 @@ get_battery_perct_bar(const char *bar)
}
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);
}

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 buf[256];
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 (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;
}
@ -685,9 +679,9 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *de
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);
@ -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 */
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);
@ -731,7 +725,7 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div, char *de
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;

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;
}
@ -364,8 +364,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
}
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;
}