Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 129350 Details for
Bug 190438
app-admin/conky-1.4.6 missing hwmon support.
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch that adds hwmon support.
conky-1.4.6-hwmon.patch (text/plain), 4.43 KB, created by
Mike DeSimone
on 2007-08-27 18:16:06 UTC
(
hide
)
Description:
Patch that adds hwmon support.
Filename:
MIME Type:
Creator:
Mike DeSimone
Created:
2007-08-27 18:16:06 UTC
Size:
4.43 KB
patch
obsolete
>diff -dpruN conky-1.4.6.orig/src/conky.c conky-1.4.6/src/conky.c >--- conky-1.4.6.orig/src/conky.c 2007-08-05 17:16:27.000000000 -0500 >+++ conky-1.4.6/src/conky.c 2007-08-27 12:03:22.000000000 -0500 >@@ -983,6 +983,7 @@ enum text_object_type { > OBJ_alignc, > OBJ_i2c, > #if defined(__linux__) >+ OBJ_hwmon, > OBJ_i8k_version, > OBJ_i8k_bios, > OBJ_i8k_serial, >@@ -1182,6 +1183,13 @@ struct text_object { > char *fmt; /* time display formatting */ > } tztime; > >+#if defined(__linux__) >+ struct { >+ enum hwmon_sensor_type type; >+ char *fname; /* filename in /sys/class/hwmon/hwmonX/device/ */ >+ } hwmon; >+#endif >+ > struct { > struct fs_stat *fs; > int w, h; >@@ -1780,6 +1788,11 @@ static void free_text_objects(unsigned i > case OBJ_acpitempf: > close(objs[i].data.i); > break; >+#if defined(__linux__) >+ case OBJ_hwmon: >+ free(objs[i].data.hwmon.fname); >+ break; >+#endif > case OBJ_i2c: > close(objs[i].data.i2c.fd); > break; >@@ -2199,6 +2212,28 @@ static struct text_object *construct_tex > strcpy(bat, "BAT0"); > } > #if defined(__linux__) >+ END OBJ(hwmon, 0) >+ if (!arg) { >+ CRIT_ERR("hwmon: needs arguments (hwmon-number, sensor type, sensor number, sensor subtype)"); >+ } else { >+ unsigned int monidx, sensidx; >+ char sensor[10], senssub[32]; >+ if (sscanf(arg, "%u %9s %u %31s", &monidx, sensor, &sensidx, senssub) != 4) { >+ CRIT_ERR("hwmon: invalid (number of) arguments"); >+ } else { >+ unsigned int maxlen = strlen(arg)+29+1+1; /* 29=strlen("/sys/class/hwmon/hwmon/device") */ >+ char fname[maxlen]; >+ snprintf(fname, maxlen, "/sys/class/hwmon/hwmon%u/device/%s%u_%s", monidx, sensor, sensidx, senssub); >+ obj->data.hwmon.fname = strdup(fname); >+ if (strncmp(sensor, "temp", 5) == 0) { >+ obj->data.hwmon.type = HWMON_temp; >+ } else if (strncmp(sensor, "fan", 4) == 0) { >+ obj->data.hwmon.type = HWMON_fan; >+ } else { >+ obj->data.hwmon.type = HWMON_other; >+ } >+ } >+ } > END OBJ(i8k_version, INFO_I8K) > END OBJ(i8k_bios, INFO_I8K) > END OBJ(i8k_serial, INFO_I8K) >@@ -3586,6 +3621,9 @@ static void generate_text_internal(char > new_fg(p, color9); > } > #if defined(__linux__) >+ OBJ(hwmon) { >+ get_hwmon_value(p, p_max_size, obj->data.hwmon.fname, obj->data.hwmon.type); >+ } > OBJ(i8k_version) { > snprintf(p, p_max_size, "%s", i8k.version); > } >diff -dpruN conky-1.4.6.orig/src/conky.h conky-1.4.6/src/conky.h >--- conky-1.4.6.orig/src/conky.h 2007-08-05 17:16:27.000000000 -0500 >+++ conky-1.4.6/src/conky.h 2007-08-27 12:03:22.000000000 -0500 >@@ -253,6 +253,11 @@ enum { > #endif > }; > >+enum hwmon_sensor_type { >+ HWMON_temp, >+ HWMON_fan, >+ HWMON_other >+}; > > /* get_battery_stuff() item selector */ > enum { >@@ -482,6 +487,8 @@ int open_i2c_sensor(const char *dev, con > char *devtype); > double get_i2c_info(int *fd, int arg, char *devtype, char *type); > >+void get_hwmon_value( char * p_client_buffer, size_t client_buffer_size, char * fname, enum hwmon_sensor_type type ); >+ > void get_adt746x_cpu( char *, size_t ); > void get_adt746x_fan( char *, size_t ); > unsigned int get_diskio(void); >diff -dpruN conky-1.4.6.orig/src/linux.c conky-1.4.6/src/linux.c >--- conky-1.4.6.orig/src/linux.c 2007-08-05 17:16:27.000000000 -0500 >+++ conky-1.4.6/src/linux.c 2007-08-27 12:03:22.000000000 -0500 >@@ -750,6 +750,37 @@ double get_i2c_info(int *fd, int div, ch > } > } > >+void get_hwmon_value( char * p_client_buffer, size_t client_buffer_size, char * fname, enum hwmon_sensor_type type ) >+{ >+ static int rep; >+ int sensor_value; >+ FILE *fp; >+ >+ if ( !p_client_buffer || client_buffer_size <= 0 || !fname ) >+ return; >+ >+ if ((fp = open_file(fname, &rep)) == NULL) { >+ snprintf( p_client_buffer, client_buffer_size, "hwmon: file '%s' not found", fname ); >+ } else { >+ fscanf(fp, "%d", &sensor_value); >+ fclose(fp); >+ /* do type-dependent stuff like conversion to more "readable" units. >+ * See Documentation/hwmon/sysfs-interface in the kernel sources for >+ * more information. >+ */ >+ switch (type) { >+ case HWMON_temp: >+ sensor_value /= 1000; /* temperatures from milli-degree to degree (celsius) */ >+ break; >+ case HWMON_fan: /* fans are in RPM - should be ok */ >+ case HWMON_other: /* keep the unit by default */ >+ default: >+ break; >+ } >+ snprintf( p_client_buffer, client_buffer_size, "%d", sensor_value ); >+ } >+} >+ > /* Prior to kernel version 2.6.12, the CPU fan speed was available > * in ADT746X_FAN_OLD, whereas later kernel versions provide this > * information in ADT746X_FAN.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 190438
: 129350 |
129352