1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 05:29:11 +00:00

hwmon leveraging existing code

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@922 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2007-08-13 23:14:01 +00:00
parent f72122bd06
commit 10a5ee6074
9 changed files with 179 additions and 122 deletions

View File

@ -1,5 +1,8 @@
# $Id$
2007-08-12
* Added $hwmon var, similar to $i2c and $platform.
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.

114
README
View File

@ -760,18 +760,17 @@ VARIABLES
Horizontal line, height is the height in pixels
hwmon N sensor number input
This has the ability to display the contents of hwmon files lo-
cated under "/sys/class/hwmon/hwmonX/device/N". For example, use
${hwmon 0 temp 1 input} to read the temperature of the CPU (in
oC) from "/sys/class/hwmon/hwmon0/device/temp1_input". If the
sensor name equals "temp", then the value read will be divided
by 1000, otherwise the number will be used unchanged. The factor
1000 is just for the Abit uGuru sensor.
hwmon (dev) type n
Hwmon sensor from sysfs (Linux 2.6). Parameter dev may be omit-
ted if you have only one hwmon device. Parameter type is either
'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Cel-
sius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n
is number of the sensor. See /sys/class/hwmon/ on your local
computer.
iconv_start codeset_from codeset_to
Convert text from one codeset to another using GNU iconv. Needs
Convert text from one codeset to another using GNU iconv. Needs
to be stopped with iconv_stop.
@ -780,11 +779,11 @@ VARIABLES
i2c (dev) type n
I2C sensor from sysfs (Linux 2.6). dev may be omitted if you
have only one I2C 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/i2c/devices/ on your local computer.
I2C sensor from sysfs (Linux 2.6). Parameter dev may be omitted
if you have only one I2C device. Parameter type is either 'in'
or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or
'tempf' (Fahrenheit) meaning temperature. Parameter n is number
of the sensor. See /sys/bus/i2c/devices/ on your local computer.
i8k_ac_status
@ -1044,28 +1043,29 @@ VARIABLES
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.
Platform sensor from sysfs (Linux 2.6). Parameter dev may be
omitted if you have only one platform device. Platform type is
either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp'
(Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter
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
passing arguments to this object. Arguments are: "host user pass
[-i interval] [-p port] [-e command]". Default port is 110, de-
[-i interval] [-p port] [-e command]". Default port is 110, de-
fault interval is 5 minutes. If the password is supplied as '*',
you will be prompted to enter the password when Conky starts.
pop3_used (args)
Displays the amount of space (in MiB, 2^20) used 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
Displays the amount of space (in MiB, 2^20) used 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.
@ -1127,36 +1127,36 @@ VARIABLES
The connection index provides you with access to each connection
in the port monitor. The monitor will return information for in-
dex values from 0 to n-1 connections. Values higher than n-1 are
simply ignored. For the "count" item, the connection index must
simply ignored. For the "count" item, the connection index must
be omitted. It is required for all other items.
Examples:
${tcp_portmon 6881 6999 count} - displays the number of connec-
${tcp_portmon 6881 6999 count} - displays the number of connec-
tions in the bittorrent port range
${tcp_portmon 22 22 rip 0} - displays the remote host ip of the
${tcp_portmon 22 22 rip 0} - displays the remote host ip of the
first sshd connection
${tcp_portmon 22 22 rip 9} - displays the remote host ip of the
${tcp_portmon 22 22 rip 9} - displays the remote host ip of the
tenth sshd connection
${tcp_portmon 1 1024 rhost 0} - displays the remote host name of
the first connection on a privileged port
${tcp_portmon 1 1024 rport 4} - displays the remote host port of
the fifth connection on a privileged port
${tcp_portmon 1 65535 lservice 14} - displays the local service
${tcp_portmon 1 65535 lservice 14} - displays the local service
name of the fifteenth connection in the range of all ports
Note that port monitor variables which share the same port range
actually refer to the same monitor, so many references to a sin-
gle port range for different items and different indexes all use
the same monitor internally. In other words, the program avoids
the same monitor internally. In other words, the program avoids
creating redundant monitors.
texeci interval command
Runs a command at an interval inside a thread and displays the
output. Same as $execi, except the command is run inside a
thread. Use this if you have a slow script to keep Conky updat-
ing. You should make the interval slightly longer then the time
it takes your script to execute. For example, if you have a
script that take 5 seconds to execute, you should make the in-
Runs a command at an interval inside a thread and displays the
output. Same as $execi, except the command is run inside a
thread. Use this if you have a slow script to keep Conky updat-
ing. You should make the interval slightly longer then the time
it takes your script to execute. For example, if you have a
script that take 5 seconds to execute, you should make the in-
terval at least 6 seconds. See also $execi.
@ -1165,8 +1165,8 @@ VARIABLES
rss url delay_in_minutes action item_num
Download and parse RSS feeds. Action may be one of the follow-
ing: feed_title, item_title (with num par), item_desc (with num
Download and parse RSS feeds. Action may be one of the follow-
ing: feed_title, item_title (with num par), item_desc (with num
par) and item_titles.
@ -1181,7 +1181,7 @@ VARIABLES
time (format)
Local time, see man strftime to get more information about for-
Local time, see man strftime to get more information about for-
mat
@ -1190,23 +1190,23 @@ VARIABLES
tztime (timezone) (format)
Local time for specified timezone, see man strftime to get more
information about format. The timezone argument is specified in
similar fashion as TZ environment variable. For hints, look in
Local time for specified timezone, see man strftime to get more
information about format. The timezone argument is specified in
similar fashion as TZ environment variable. For hints, look in
/usr/share/zoneinfo. e.g. US/Pacific, Europe/Zurich, etc.
totaldown net
Total download, overflows at 4 GB on Linux with 32-bit arch and
Total download, overflows at 4 GB on Linux with 32-bit arch and
there doesn't seem to be a way to know how many times it has al-
ready done that before conky has started.
top type, num
This takes arguments in the form:top (name) (number) Basically,
processes are ranked from highest to lowest in terms of cpu us-
age, which is what (num) represents. The types are: "name",
"pid", "cpu", and "mem". There can be a max of 10 processes
This takes arguments in the form:top (name) (number) Basically,
processes are ranked from highest to lowest in terms of cpu us-
age, which is what (num) represents. The types are: "name",
"pid", "cpu", and "mem". There can be a max of 10 processes
listed.
@ -1230,9 +1230,9 @@ VARIABLES
Upload speed in kilobytes with one decimal
upspeedgraph net (height),(width) (gradient colour 1) (gradient colour
upspeedgraph net (height),(width) (gradient colour 1) (gradient colour
2) (scale)
Upload speed graph, colours defined in hex, minus the #. If
Upload speed graph, colours defined in hex, minus the #. If
scale is non-zero, it becomes the scale for the graph.
@ -1244,12 +1244,12 @@ VARIABLES
voffset (pixels)
Change vertical offset by N pixels. Negative values will cause
Change vertical offset by N pixels. Negative values will cause
text to overlap. See also $offset.
voltage_mv (n)
Returns CPU #n's voltage in mV. CPUs are counted from 1. If
Returns CPU #n's voltage in mV. CPUs are counted from 1. If
omitted, the parameter defaults to 1.
@ -1377,11 +1377,11 @@ FILES
BUGS
Drawing to root or some other desktop window directly doesn't work with
all window managers. Especially doesn't work well with Gnome and it has
been reported that it doesn't work with KDE either. Nautilus can be
disabled from drawing to desktop with program gconf-editor. Uncheck
show_desktop in /apps/nautilus/preferences/. There is -w switch in
Conky to set some specific window id. You might find xwininfo -tree
useful to find the window to draw to. You can also use -o argument
been reported that it doesn't work with KDE either. Nautilus can be
disabled from drawing to desktop with program gconf-editor. Uncheck
show_desktop in /apps/nautilus/preferences/. There is -w switch in
Conky to set some specific window id. You might find xwininfo -tree
useful to find the window to draw to. You can also use -o argument
which makes Conky to create its own window.
SEE ALSO

View File

@ -729,8 +729,8 @@ Displays first N lines of supplied text text file. If interval is not supplied,
Horizontal line, height is the height in pixels
.TP
\fB\*(T<\fBhwmon\fR\*(T>\fR \*(T<\fBN sensor number input\fR\*(T>
This has the ability to display the contents of hwmon files located under "/sys/class/hwmon/hwmonX/device/N". For example, use ${hwmon 0 temp 1 input} to read the temperature of the CPU (in \(deC) from "/sys/class/hwmon/hwmon0/device/temp1_input". If the sensor name equals "temp", then the value read will be divided by 1000, otherwise the number will be used unchanged. The factor 1000 is just for the Abit uGuru sensor.
\fB\*(T<\fBhwmon\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T>
Hwmon sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one hwmon device. Parameter type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/class/hwmon/ on your local computer.
.TP
\fB\*(T<\fBiconv_start\fR\*(T>\fR \*(T<\fBcodeset_from codeset_to\fR\*(T>
@ -742,7 +742,7 @@ Stop iconv codeset conversion.
.TP
\fB\*(T<\fBi2c\fR\*(T>\fR \*(T<\fB(dev) type n\fR\*(T>
I2C sensor from sysfs (Linux 2.6). dev may be omitted if you have only one I2C 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/i2c/devices/ on your local computer.
I2C sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one I2C device. Parameter type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/bus/i2c/devices/ on your local computer.
.TP
\fB\*(T<\fBi8k_ac_status\fR\*(T>\fR
@ -970,9 +970,7 @@ 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.
Platform sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one platform device. Platform type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter 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>

View File

@ -800,13 +800,13 @@
</varlistentry>
<varlistentry>
<term>
<command><option>hwmon</option></command>
<option>N sensor number input</option>
</term>
<listitem>
This has the ability to display the contents of hwmon files located under "/sys/class/hwmon/hwmonX/device/N". For example, use ${hwmon 0 temp 1 input} to read the temperature of the CPU (in °C) from "/sys/class/hwmon/hwmon0/device/temp1_input". If the sensor name equals "temp", then the value read will be divided by 1000, otherwise the number will be used unchanged. The factor 1000 is just for the Abit uGuru sensor.
<para></para></listitem>
<term>
<command><option>hwmon</option></command>
<option>(dev) type n</option>
</term>
<listitem>
Hwmon sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one hwmon device. Parameter type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/class/hwmon/ on your local computer.
<para></para></listitem>
</varlistentry>
<varlistentry>
@ -835,7 +835,7 @@
<option>(dev) type n</option>
</term>
<listitem>
I2C sensor from sysfs (Linux 2.6). dev may be omitted if you have only one I2C 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/i2c/devices/ on your local computer.
I2C sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one I2C device. Parameter type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/bus/i2c/devices/ on your local computer.
<para></para></listitem>
</varlistentry>
@ -1345,9 +1345,7 @@
<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.
Platform sensor from sysfs (Linux 2.6). Parameter dev may be omitted if you have only one platform device. Platform type is either 'in' or 'vol' meaning voltage; 'fan' meaning fan; 'temp' (Celsius) or 'tempf' (Fahrenheit) meaning temperature. Parameter n is number of the sensor. See /sys/bus/platform/devices/ on your local computer.
<para></para></listitem>
</varlistentry>

View File

@ -1002,6 +1002,8 @@ enum text_object_type {
OBJ_alignr,
OBJ_alignc,
OBJ_i2c,
OBJ_platform,
OBJ_hwmon,
#if defined(__linux__)
OBJ_i8k_version,
OBJ_i8k_bios,
@ -1056,7 +1058,6 @@ enum text_object_type {
OBJ_mixerrbar,
OBJ_new_mails,
OBJ_nodename,
OBJ_platform,
OBJ_pre_exec,
OBJ_processes,
OBJ_running_processes,
@ -1226,7 +1227,7 @@ struct text_object {
int arg;
char devtype[256];
char type[64];
} i2c, platform; /* 2 */
} sysfs; /* 2 */
struct {
int pos;
@ -1811,10 +1812,13 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
close(objs[i].data.i);
break;
case OBJ_i2c:
close(objs[i].data.i2c.fd);
close(objs[i].data.sysfs.fd);
break;
case OBJ_platform:
close(objs[i].data.platform.fd);
close(objs[i].data.sysfs.fd);
break;
case OBJ_hwmon:
close(objs[i].data.sysfs.fd);
break;
#endif /* !__OpenBSD__ */
case OBJ_time:
@ -2596,7 +2600,7 @@ 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)
END OBJ(i2c, INFO_SYSFS)
char buf1[64], buf2[64];
int n;
@ -2610,16 +2614,16 @@ 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 */
sscanf(arg, "%63s %d", buf2, &n);
obj->data.i2c.fd =
open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg, obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63);
obj->data.sysfs.fd =
open_i2c_sensor(0, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
strncpy(obj->data.sysfs.type, buf2, 63);
} else {
obj->data.i2c.fd =
open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg, obj->data.i2c.devtype);
strncpy(obj->data.i2c.type, buf2, 63);
obj->data.sysfs.fd =
open_i2c_sensor(buf1, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
strncpy(obj->data.sysfs.type, buf2, 63);
}
END OBJ(platform, INFO_PLATFORM)
END OBJ(platform, INFO_SYSFS)
char buf1[64], buf2[64];
int n;
@ -2632,13 +2636,35 @@ 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 */
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);
obj->data.sysfs.fd =
open_platform_sensor(0, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
strncpy(obj->data.sysfs.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);
obj->data.sysfs.fd =
open_platform_sensor(buf1, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
strncpy(obj->data.sysfs.type, buf2, 63);
}
END OBJ(hwmon, INFO_SYSFS)
char buf1[64], buf2[64];
int n;
if (!arg) {
ERR("hwmon needs argumanets");
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.sysfs.fd =
open_hwmon_sensor(0, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
strncpy(obj->data.sysfs.type, buf2, 63);
} else {
obj->data.sysfs.fd =
open_hwmon_sensor(buf1, buf2, n, &obj->data.sysfs.arg, obj->data.sysfs.devtype);
strncpy(obj->data.sysfs.type, buf2, 63);
}
#endif /* !__OpenBSD__ */
@ -2969,14 +2995,14 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(sysname, 0)
#ifndef __OpenBSD__
END OBJ(temp1, INFO_I2C) obj->type = OBJ_i2c;
obj->data.i2c.fd =
open_i2c_sensor(0, "temp", 1, &obj->data.i2c.arg,
obj->data.i2c.devtype);
END OBJ(temp2, INFO_I2C) obj->type = OBJ_i2c;
obj->data.i2c.fd =
open_i2c_sensor(0, "temp", 2, &obj->data.i2c.arg,
obj->data.i2c.devtype);
END OBJ(temp1, INFO_SYSFS) obj->type = OBJ_i2c;
obj->data.sysfs.fd =
open_i2c_sensor(0, "temp", 1, &obj->data.sysfs.arg,
obj->data.sysfs.devtype);
END OBJ(temp2, INFO_SYSFS) obj->type = OBJ_i2c;
obj->data.sysfs.fd =
open_i2c_sensor(0, "temp", 2, &obj->data.sysfs.arg,
obj->data.sysfs.devtype);
#endif
END OBJ(time, 0) obj->data.s = strdup(arg ? arg : "%F %T");
END OBJ(utime, 0) obj->data.s = strdup(arg ? arg : "%F %T");
@ -4491,10 +4517,10 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
OBJ(i2c) {
double r;
r = get_sysbus_info(&obj->data.i2c.fd,
obj->data.i2c.arg,
obj->data.i2c.devtype,
obj->data.i2c.type);
r = get_sysfs_info(&obj->data.sysfs.fd,
obj->data.sysfs.arg,
obj->data.sysfs.devtype,
obj->data.sysfs.type);
if (r >= 100.0 || r == 0)
snprintf(p, p_max_size, "%d", (int) r);
@ -4504,16 +4530,29 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
OBJ(platform) {
double r;
r = get_sysbus_info(&obj->data.platform.fd,
obj->data.platform.arg,
obj->data.platform.devtype,
obj->data.platform.type);
r = get_sysfs_info(&obj->data.sysfs.fd,
obj->data.sysfs.arg,
obj->data.sysfs.devtype,
obj->data.sysfs.type);
if (r >= 100.0 || r == 0)
snprintf(p, p_max_size, "%d", (int) r);
else
snprintf(p, p_max_size, "%.1f", r);
}
OBJ(hwmon) {
double r;
r = get_sysfs_info(&obj->data.sysfs.fd,
obj->data.sysfs.arg,
obj->data.sysfs.devtype,
obj->data.sysfs.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);

View File

@ -249,7 +249,7 @@ enum {
INFO_UPTIME = 6,
INFO_BUFFERS = 7,
INFO_FS = 8,
INFO_I2C = 9,
INFO_SYSFS = 9,
INFO_MIXER = 10,
INFO_LOADAVG = 11,
INFO_UNAME = 12,
@ -277,7 +277,6 @@ enum {
#ifdef RSS
INFO_RSS = 24,
#endif
INFO_PLATFORM = 25
};
@ -505,14 +504,17 @@ 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_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype);
int open_sysfs_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)
open_sysfs_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)
open_sysfs_sensor("/sys/bus/platform/devices/",dev,type,n,div,devtype)
double get_sysbus_info(int *fd, int arg, char *devtype, char *type);
#define open_hwmon_sensor(dev,type,n,div,devtype) \
open_sysfs_sensor("/sys/class/hwmon/",dev,type,n,div,devtype); \
double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
void get_adt746x_cpu( char *, size_t );
void get_adt746x_fan( char *, size_t );

View File

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

View File

@ -659,14 +659,16 @@ get_first_file_in_a_directory(const char *dir, char *s, int *rep)
}
}
int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, int *div, char *devtype)
{
char path[256];
char buf[256];
int fd;
int divfd;
/* if i2c device is NULL or *, get first */
memset (buf, 0, sizeof(buf));
/* if device is NULL or *, get first */
if (dev == NULL || strcmp(dev, "*") == 0) {
static int rep = 0;
if (!get_first_file_in_a_directory(dir, buf, &rep))
@ -674,6 +676,20 @@ int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n
dev = buf;
}
if (strcmp (dir, "/sys/class/hwmon/")==0) {
if (*buf) {
/* buf holds result from get_first_file_in_a_directory() above,
* e.g. "hwmon0" -- append "/device" */
strcat (buf,"/device");
}
else {
/* dev holds device number N as a string,
* e.g. "0", -- convert to "hwmon0/device" */
sprintf (buf,"hwmon%s/device",dev);
dev = buf;
}
}
/* change vol to in */
if (strcmp(type, "vol") == 0)
type = "in";
@ -688,7 +704,8 @@ int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n
/* open file */
fd = open(path, O_RDONLY);
if (fd < 0) {
CRIT_ERR("can't open '%s': %s\nplease check your device or remove this var from Conky", path, strerror(errno));
CRIT_ERR("can't open '%s': %s\nplease check your device or remove this var from Conky",
path, strerror(errno));
}
if (strcmp(type, "in") == 0 || strcmp(type, "temp") == 0
@ -725,7 +742,7 @@ int open_sysbus_sensor(const char *dir, const char *dev, const char *type, int n
return fd;
}
double get_sysbus_info(int *fd, int div, char *devtype, char *type)
double get_sysfs_info(int *fd, int div, char *devtype, char *type)
{
int val = 0;

View File

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