Attached are updated and new patches for the sysutils/conky port. The patches enable the ${apm_adapter}, ${apm_battery_life}, and ${apm_battery_time} variables in conky on amd64. There is also a patch to the man page explaining these variables are also available on OpenBSD.
I made these patches on the conky port from the OPENBSD_4_8 branch. I am not sure if current has an updated conky port, but I do know that at least the latest stable upstream conky release does not have these patches. I've submitted these fixes to the upstream maintainers. I've been using these patches now for a few days and everything appears fine to me. -- David Cantrell <david.l.cantr...@gmail.com> KB1PCX | http://blog.burdell.org/
$OpenBSD$ --- doc/conky.1.orig Mon Aug 24 12:59:12 2009 +++ doc/conky.1 Thu Feb 24 07:18:42 2011 @@ -736,18 +736,17 @@ Prints the UPS mode (e.g. standalone). .TP \fB\*(T<\fBapm_adapter\fR\*(T> \fR -Display APM AC adapter status (FreeBSD only) +Display APM AC adapter status (FreeBSD and OpenBSD only) .TP \fB\*(T<\fBapm_battery_life\fR\*(T> \fR -Display APM battery life in percent (FreeBSD -only) +Display APM battery life in percent (FreeBSD and OpenBSD only) .TP \fB\*(T<\fBapm_battery_time\fR\*(T> \fR Display remaining APM battery life in hh:mm:ss or "unknown" if AC adapterstatus is on-line or charging -(FreeBSD only) +(FreeBSD and OpenBSD only) .TP \fB\*(T<\fBaudacious_bar\fR\*(T> \fR\*(T<\fB(height),(width)\fR\*(T>
$OpenBSD$ --- src/conky.c.orig Mon Aug 10 13:44:18 2009 +++ src/conky.c Thu Feb 24 08:01:44 2011 @@ -97,7 +97,8 @@ /* FIXME: apm_getinfo is unused here. maybe it's meant for common.c */ #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ - || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) + || defined(__OpenBSD__)) \ + && (defined(i386) || defined(__i386__) || defined(__amd64__)) int apm_getinfo(int fd, apm_info_t aip); char *get_apm_adapter(void); char *get_apm_battery_life(void); @@ -2585,7 +2586,8 @@ static struct text_object *construct_text_object(const END OBJ(adt746xfan, 0) #endif /* !__OpenBSD__ */ #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ - || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) + || defined(__OpenBSD__)) \ + && (defined(i386) || defined(__i386__) || defined(__amd64__)) END OBJ(apm_adapter, 0) END OBJ(apm_battery_life, 0) END OBJ(apm_battery_time, 0) @@ -5171,7 +5173,8 @@ static void generate_text_internal(char *p, int p_max_ snprintf(p, p_max_size, "%d", cur->users.number); } #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ - || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) + || defined(__OpenBSD__)) \ + && (defined(i386) || defined(__i386__) || defined(__amd64__)) OBJ(apm_adapter) { char *msg;
$OpenBSD: patch-src_openbsd_c,v 1.8 2010/04/27 20:56:11 sthen Exp $ --- src/openbsd.c.orig Sat Aug 8 10:05:55 2009 +++ src/openbsd.c Thu Feb 24 07:39:32 2011 @@ -454,14 +454,13 @@ void update_obsd_sensors() dev = obsd_sensors.device; // FIXME: read more than one device - /* for (dev = 0; dev < MAXSENSORDEVICES; dev++) { */ + for (dev = 0; dev < MAXSENSORDEVICES; dev++) { mib[2] = dev; if (sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) == -1) { - if (errno != ENOENT) { - warn("sysctl"); - } - return; - // continue; + if (errno == ENOENT) /* end of sensors */ + return; + if (errno == ENXIO) /* missing e.g. usb sensor that was unplugged */ + continue; } for (type = 0; type < SENSOR_MAX_TYPES; type++) { mib[3] = type; @@ -496,7 +495,8 @@ void update_obsd_sensors() sensor_cnt++; } } - /* } */ + break; // FIXME: read more than one device + } init_sensors = 1; } @@ -539,7 +539,7 @@ void get_obsd_product(char *buf, size_t client_buffer_ /* rdtsc() and get_freq_dynamic() copied from linux.c */ -#if defined(__i386) || defined(__x86_64) +#if defined(__i386) || defined(__amd64) __inline__ unsigned long long int rdtsc() { unsigned long long int x; @@ -553,7 +553,7 @@ __inline__ unsigned long long int rdtsc() void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size, const char *p_format, int divisor) { -#if defined(__i386) || defined(__x86_64) +#if defined(__i386) || defined(__amd64) struct timezone tz; struct timeval tvstart, tvstop; unsigned long long cycles[2]; /* gotta be 64 bit */ @@ -786,7 +786,7 @@ inline void proc_find_top(struct process **cpu, struct free(processes); } -#if defined(i386) || defined(__i386__) +#if defined(i386) || defined(__i386__) || defined(__amd64__) #define APMDEV "/dev/apm" #define APM_UNKNOWN 255
$OpenBSD: patch-src_openbsd_h,v 1.3 2010/04/27 20:56:11 sthen Exp $ --- src/openbsd.h.orig Sat Aug 8 10:05:55 2009 +++ src/openbsd.h Thu Feb 24 07:41:04 2011 @@ -11,6 +11,9 @@ void update_obsd_sensors(void); void get_obsd_vendor(char *buf, size_t client_buffer_size); void get_obsd_product(char *buf, size_t client_buffer_size); +#ifndef MAXSENSORDEVICES +#define MAXSENSORDEVICES 1024 +#endif #define OBSD_MAX_SENSORS 256 struct obsd_sensors_struct { int device; @@ -20,33 +23,7 @@ struct obsd_sensors_struct { }; struct obsd_sensors_struct obsd_sensors; -#if defined(i386) || defined(__i386__) -typedef struct apm_power_info *apm_info_t; -#endif - -#endif /*OPENBSD_H_*/ -#ifndef OPENBSD_H_ -#define OPENBSD_H_ - -#include "common.h" -#include <sys/sysctl.h> -#include <sys/sensors.h> -#include <machine/apmvar.h> - -void update_obsd_sensors(void); -void get_obsd_vendor(char *buf, size_t client_buffer_size); -void get_obsd_product(char *buf, size_t client_buffer_size); - -#define OBSD_MAX_SENSORS 256 -struct obsd_sensors_struct { - int device; - float temp[MAXSENSORDEVICES][OBSD_MAX_SENSORS]; - unsigned int fan[MAXSENSORDEVICES][OBSD_MAX_SENSORS]; - float volt[MAXSENSORDEVICES][OBSD_MAX_SENSORS]; -}; -struct obsd_sensors_struct obsd_sensors; - -#if defined(i386) || defined(__i386__) +#if defined(i386) || defined(__i386__) || defined(__amd64__) typedef struct apm_power_info *apm_info_t; #endif
$OpenBSD$ --- src/text_object.h.orig Sat Aug 8 10:05:55 2009 +++ src/text_object.h Thu Feb 24 07:59:45 2011 @@ -278,7 +278,8 @@ enum text_object_type { OBJ_pop3_unseen, OBJ_pop3_used, #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ - || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) + || defined(__OpenBSD__)) \ + && (defined(i386) || defined(__i386__) || defined(__amd64__)) OBJ_apm_adapter, OBJ_apm_battery_time, OBJ_apm_battery_life,