diff options
author | imil <imil> | 2012-05-13 08:42:20 +0000 |
---|---|---|
committer | imil <imil> | 2012-05-13 08:42:20 +0000 |
commit | 7ab683cee3d8425942f8a304141aac8215c0d6fb (patch) | |
tree | 2e922d7361fc524e7ac55e8b487753efbce3c79a /sysutils/conky | |
parent | 5b35c9d16e1bf07c051fe55f547ce81a780a5e00 (diff) | |
download | pkgsrc-7ab683cee3d8425942f8a304141aac8215c0d6fb.tar.gz |
Initial import of conky, version 1.9.0, into the NetBSD Packages Collection.
Conky is a system monitor for X originally based on torsmo. Since
its inception, Conky has changed significantly from its predecessor,
while maintaining simplicity and configurability. Conky can display
just about anything, either on your root desktop or in its own
window. Not only does Conky have many built-in objects, it can
also display just about any piece of information by using scripts
and other external programs.
Conky has more than 250 built in objects, including support for a
plethora of OS stats (uname, uptime, CPU usage, mem usage, disk
usage, "top" like process stats, and network monitoring, just to
name a few), built in IMAP and POP3 support, built in support for
many popular music players (MPD, XMMS2, BMPx, Audacious), and much
much more. Conky can display this info either as text, or using
simple progress bars and graph widgets, with different fonts
and colours.
Diffstat (limited to 'sysutils/conky')
-rw-r--r-- | sysutils/conky/DESCR | 16 | ||||
-rw-r--r-- | sysutils/conky/Makefile | 53 | ||||
-rw-r--r-- | sysutils/conky/PLIST | 8 | ||||
-rw-r--r-- | sysutils/conky/distinfo | 15 | ||||
-rw-r--r-- | sysutils/conky/files/conkyrc | 78 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-configure.ac | 58 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-data_Makefile.am | 15 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_Makefile.am | 19 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_config.h.in | 36 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_conky.c | 114 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_core.c | 71 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_fs.c | 69 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_netbsd.c | 1017 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_netbsd.h | 36 | ||||
-rw-r--r-- | sysutils/conky/patches/patch-src_text__object.h | 25 |
15 files changed, 1630 insertions, 0 deletions
diff --git a/sysutils/conky/DESCR b/sysutils/conky/DESCR new file mode 100644 index 00000000000..f28e85d0ca1 --- /dev/null +++ b/sysutils/conky/DESCR @@ -0,0 +1,16 @@ +Conky is a system monitor for X originally based on torsmo. Since +its inception, Conky has changed significantly from its predecessor, +while maintaining simplicity and configurability. Conky can display +just about anything, either on your root desktop or in its own +window. Not only does Conky have many built-in objects, it can +also display just about any piece of information by using scripts +and other external programs. + +Conky has more than 250 built in objects, including support for a +plethora of OS stats (uname, uptime, CPU usage, mem usage, disk +usage, "top" like process stats, and network monitoring, just to +name a few), built in IMAP and POP3 support, built in support for +many popular music players (MPD, XMMS2, BMPx, Audacious), and much +much more. Conky can display this info either as text, or using +simple progress bars and graph widgets, with different fonts +and colours. diff --git a/sysutils/conky/Makefile b/sysutils/conky/Makefile new file mode 100644 index 00000000000..d0eadda0faf --- /dev/null +++ b/sysutils/conky/Makefile @@ -0,0 +1,53 @@ +# $NetBSD: Makefile,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ +# + +DISTNAME= conky-1.9.0 +CATEGORIES= sysutils +MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=conky/} +EXTRACT_SUFX= .tar.bz2 + +MAINTAINER= imil@NetBSD.org +HOMEPAGE= http://conky.sourceforge.net/ +COMMENT= Free, light-weight system monitor for X +LICENSE= gnu-gpl-v3 + +PKG_DESTDIR_SUPPORT= user-destdir + +GNU_CONFIGURE= yes +USE_LIBTOOL= yes +USE_TOOLS+= pkg-config aclocal autoconf autoheader automake + +CONFIGURE_ARGS+= --enable-imlib2 --enable-lua-imlib2 +CONFIGURE_ARGS+= --enable-lua-cairo +CONFIGURE_ARGS+= --enable-curl --enable-rss +CONFIGURE_ARGS+= --enable-weather-metar --enable-weather-xoap + +EGDIR= share/examples/conky +OWN_DIRS= ${PKG_SYSCONFDIR}/conky +CONF_FILES= ${EGDIR}/conky.conf ${PKG_SYSCONFDIR}/conky/conky.conf +CONF_FILES+= ${EGDIR}/conky_no_x11.conf ${PKG_SYSCONFDIR}/conky/conky_no_x11.conf + +.include "../../mk/bsd.prefs.mk" + +# conky segfaults on system's curses +PREFER_PKGSRC+= ncurses + +pre-configure: + set -e; cd ${WRKSRC}; \ + aclocal; autoheader; automake -a --foreign -i; autoconf + +post-install: + ${INSTALL_DATA} files/conkyrc ${DESTDIR}${PREFIX}/${EGDIR} + +.include "../../devel/ncurses/buildlink3.mk" +.include "../../devel/tolua++/buildlink3.mk" +.include "../../x11/libX11/buildlink3.mk" +.include "../../x11/libXext/buildlink3.mk" +.include "../../x11/libXdamage/buildlink3.mk" +.include "../../x11/libXft/buildlink3.mk" +.include "../../graphics/cairo/buildlink3.mk" +.include "../../graphics/imlib2/buildlink3.mk" +.include "../../www/curl/buildlink3.mk" +.include "../../devel/glib2/buildlink3.mk" +.include "../../textproc/libxml2/buildlink3.mk" +.include "../../mk/bsd.pkg.mk" diff --git a/sysutils/conky/PLIST b/sysutils/conky/PLIST new file mode 100644 index 00000000000..e9991d098d6 --- /dev/null +++ b/sysutils/conky/PLIST @@ -0,0 +1,8 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ +bin/conky +lib/conky/libcairo.la +lib/conky/libimlib2.la +man/man1/conky.1 +share/examples/conky/conky.conf +share/examples/conky/conky_no_x11.conf +share/examples/conky/conkyrc diff --git a/sysutils/conky/distinfo b/sysutils/conky/distinfo new file mode 100644 index 00000000000..6ccddfcef65 --- /dev/null +++ b/sysutils/conky/distinfo @@ -0,0 +1,15 @@ +$NetBSD: distinfo,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +SHA1 (conky-1.9.0.tar.bz2) = 2069cbdb8e7224fcbf3c6b1ddebf64a51634b4cc +RMD160 (conky-1.9.0.tar.bz2) = 2df0e60d4236ed667bdae876e11ba28d05914e25 +Size (conky-1.9.0.tar.bz2) = 626555 bytes +SHA1 (patch-configure.ac) = 3ccad4907e84145ea7c4cc8c7eba81ed5ac48185 +SHA1 (patch-data_Makefile.am) = af8df32076b8a389ee98e2550342dbb343f7bff3 +SHA1 (patch-src_Makefile.am) = f4e79c0f08a0886a061449b9a8a578173cda90db +SHA1 (patch-src_config.h.in) = 31aa9cd4bd4ab775e6da633f86415ee8f5383538 +SHA1 (patch-src_conky.c) = e4c9173661cca437af0febbcae94eec72dc0ea4a +SHA1 (patch-src_core.c) = a64ff7cb05d7b6b62aea41e486c0a719e2c93faf +SHA1 (patch-src_fs.c) = 104fd3788f319689026702d6a149410184072e24 +SHA1 (patch-src_netbsd.c) = 33da80a5f26fd47590a42bb7dd08f1db9f5f9a00 +SHA1 (patch-src_netbsd.h) = 25f9c66eede8e4aaef475d6afcbf79440ec8d7bb +SHA1 (patch-src_text__object.h) = 7f7e3684e21f9618a8ede37525f4a48f47a92050 diff --git a/sysutils/conky/files/conkyrc b/sysutils/conky/files/conkyrc new file mode 100644 index 00000000000..13969e9f30a --- /dev/null +++ b/sysutils/conky/files/conkyrc @@ -0,0 +1,78 @@ +# Inspired from http://ebupof.deviantart.com/art/My-Conky-Config-1-3-60095106 + +background no +font Sans:size=8 +use_xft yes +xftalpha 0.9 +update_interval 3.0 +total_run_times 0 +own_window no +own_window_type desktop +own_window_transparent yes +own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager +double_buffer yes +minimum_size 220 5 +maximum_width 220 +draw_shades yes +draw_outline no +draw_borders no +draw_graph_borders yes +default_color white +default_shade_color black +default_outline_color green +alignment top_right +gap_x 12 +gap_y 35 +no_buffers yes +uppercase no +cpu_avg_samples 2 +override_utf8_locale no +uppercase yes # set to yes if you want all text to be in uppercase + +TEXT +${color white}SYSTEM ${hr 1}${color} + +Hostname: $alignr$nodename +Kernel: $alignr$kernel +Uptime: $alignr$uptime +Temp: ${alignr}${acpitemp}C + +CPU: ${alignr}${freq} MHz +Processes: ${alignr}$processes ($running_processes running) +Load: ${alignr}$loadavg + +CPU1 ${alignr}${cpu cpu1}% +${cpugraph cpu1 10,100} +CPU2 ${alignr}${cpu cpu2}% +${cpugraph cpu2 10,100} + +Ram ${alignr}$mem / $memmax ($memperc%) +${membar 4} +swap ${alignr}$swap / $swapmax ($swapperc%) +${swapbar 4} + +Highest CPU $alignr CPU% MEM% +${top name 1}$alignr${top cpu 1}${top mem 1} +${top name 2}$alignr${top cpu 2}${top mem 2} +${top name 3}$alignr${top cpu 3}${top mem 3} + +Highest MEM $alignr CPU% MEM% +${top_mem name 1}$alignr${top_mem cpu 1}${top_mem mem 1} +${top_mem name 2}$alignr${top_mem cpu 2}${top_mem mem 2} +${top_mem name 3}$alignr${top_mem cpu 3}${top_mem mem 3} + +${color white}Filesystem ${hr 1}${color} + +Root: ${alignr}${fs_free /} / ${fs_size /} +${fs_bar 4 /} + +${color white}NETWORK ${hr 1}${color} + +Down ${downspeed ath0} k/s ${alignr}Up ${upspeed ath0} k/s +${downspeedgraph ath0 25,107} ${alignr}${upspeedgraph ath0 25,107} +Total ${totaldown ath0} ${alignr}Total ${totalup ath0} + +${color white}BATTERY ${hr 1}${color} + +${alignr}${battery} +Remaining: ${alignr}${battery_time} diff --git a/sysutils/conky/patches/patch-configure.ac b/sysutils/conky/patches/patch-configure.ac new file mode 100644 index 00000000000..109eeb00029 --- /dev/null +++ b/sysutils/conky/patches/patch-configure.ac @@ -0,0 +1,58 @@ +$NetBSD: patch-configure.ac,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Enable NetBSD as a suitable platform. + +--- configure.ac.orig 2012-05-03 21:47:32.000000000 +0000 ++++ configure.ac +@@ -62,10 +62,11 @@ case $uname in + WANT_DEVSTAT=yes + WANT_OPTRESET=yes + ;; +-# NetBSD*) +-# WANT_KVM=yes +-# WANT_OSSLIB=yes +-# ;; ++ NetBSD*) ++ WANT_KVM=yes ++ WANT_OSSLIB=yes ++ WANT_PROPLIB=yes ++ ;; + + OpenBSD*) + WANT_KVM=yes +@@ -87,7 +88,7 @@ esac + AM_CONDITIONAL(BUILD_LINUX, test x$uname = xLinux) + #AM_CONDITIONAL(BUILD_SOLARIS, test x$uname = xSunOS) + AM_CONDITIONAL(BUILD_FREEBSD, test x$uname = xFreeBSD -o x$uname = xGNU/kFreeBSD) +-#AM_CONDITIONAL(BUILD_NETBSD, test x$uname = xNetBSD) ++AM_CONDITIONAL(BUILD_NETBSD, test x$uname = xNetBSD) + AM_CONDITIONAL(BUILD_OPENBSD, test x$uname = xOpenBSD) + + BUILD_DATE=$(LANG=en_US LC_ALL=en_US LOCALE=en_US date) +@@ -734,6 +735,17 @@ if test x$WANT_KVM = xyes; then + fi + + dnl ++dnl PROPLIB for NetBSD ++dnl ++ ++if test x$WANT_PROPLIB = xyes; then ++ AC_CHECK_LIB(prop, prop_dictionary_create, ++ conky_LIBS="$conky_LIBS -lprop", ++ AC_MSG_ERROR([Could not find prop_dictionary_create in -lprop.]) ++ ) ++fi ++ ++dnl + dnl optreset + dnl + +@@ -784,7 +796,7 @@ dnl + dnl Some headers + dnl + +-AC_CHECK_HEADERS([signal.h unistd.h sys/utsname.h sys/stat.h linux/soundcard.h alsa/asoundlib.h dirent.h mcheck.h \ ++AC_CHECK_HEADERS([signal.h unistd.h sys/utsname.h sys/stat.h linux/soundcard.h alsa/asoundlib.h dirent.h mcheck.h sys/statvfs.h \ + sys/statfs.h sys/param.h pthread.h semaphore.h assert.h errno.h time.h]) + AC_CHECK_HEADERS([sys/mount.h], [], [], + [#ifdef HAVE_SYS_PARAM_H diff --git a/sysutils/conky/patches/patch-data_Makefile.am b/sysutils/conky/patches/patch-data_Makefile.am new file mode 100644 index 00000000000..ca975990219 --- /dev/null +++ b/sysutils/conky/patches/patch-data_Makefile.am @@ -0,0 +1,15 @@ +$NetBSD: patch-data_Makefile.am,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Install config into example directory. + +--- data/Makefile.am.orig 2010-10-20 00:32:27.000000000 +0000 ++++ data/Makefile.am +@@ -25,7 +25,7 @@ + # along with this program. If not, see <http://www.gnu.org/licenses/>. + # + +-configdir = ${sysconfdir}/conky ++configdir = ${prefix}/share/examples/conky + dist_config_DATA = conky.conf conky_no_x11.conf + + # vi:set ts=4 sw=4 noet ai nocindent syntax=automake: diff --git a/sysutils/conky/patches/patch-src_Makefile.am b/sysutils/conky/patches/patch-src_Makefile.am new file mode 100644 index 00000000000..63984a4aaab --- /dev/null +++ b/sysutils/conky/patches/patch-src_Makefile.am @@ -0,0 +1,19 @@ +$NetBSD: patch-src_Makefile.am,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Enable NetBSD as a suitable platform. + +--- src/Makefile.am.orig 2012-05-03 21:08:27.000000000 +0000 ++++ src/Makefile.am +@@ -119,9 +119,9 @@ endif + if BUILD_FREEBSD + optional_sources += $(freebsd) + endif +-#if BUILD_NETBSD +-#optional_sources += $(netbsd) +-#endif ++if BUILD_NETBSD ++optional_sources += $(netbsd) ++endif + if BUILD_OPENBSD + optional_sources += $(openbsd) + endif diff --git a/sysutils/conky/patches/patch-src_config.h.in b/sysutils/conky/patches/patch-src_config.h.in new file mode 100644 index 00000000000..a1098b7cfac --- /dev/null +++ b/sysutils/conky/patches/patch-src_config.h.in @@ -0,0 +1,36 @@ +$NetBSD: patch-src_config.h.in,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Check for sys/statvfs.h. + +--- src/config.h.in.orig 2012-05-03 21:47:46.000000000 +0000 ++++ src/config.h.in +@@ -102,9 +102,6 @@ + /* Define to 1 if you have the <glib-object.h> header file. */ + #undef HAVE_GLIB_OBJECT_H + +-/* Define if you have the iconv() function and it works. */ +-#undef HAVE_ICONV +- + /* Define to 1 if you have the <inttypes.h> header file. */ + #undef HAVE_INTTYPES_H + +@@ -207,6 +204,9 @@ + /* Define to 1 if you have the <sys/statfs.h> header file. */ + #undef HAVE_SYS_STATFS_H + ++/* Define to 1 if you have the <sys/statvfs.h> header file. */ ++#undef HAVE_SYS_STATVFS_H ++ + /* Define to 1 if you have the <sys/stat.h> header file. */ + #undef HAVE_SYS_STAT_H + +@@ -234,9 +234,6 @@ + /* Define if you want support for IBM/Lenovo notebooks (SMAPI) */ + #undef IBM + +-/* Define as const if the declaration of iconv() needs const. */ +-#undef ICONV_CONST +- + /* Define if you want Imlib2 support */ + #undef IMLIB2 + diff --git a/sysutils/conky/patches/patch-src_conky.c b/sysutils/conky/patches/patch-src_conky.c new file mode 100644 index 00000000000..054c7d61633 --- /dev/null +++ b/sysutils/conky/patches/patch-src_conky.c @@ -0,0 +1,114 @@ +$NetBSD: patch-src_conky.c,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Enable NetBSD as a suitable platform. + +--- src/conky.c.orig 2012-05-03 21:22:21.000000000 +0000 ++++ src/conky.c +@@ -65,7 +65,7 @@ + #include <fcntl.h> + #include <getopt.h> + #ifdef NCURSES +-#include <ncurses.h> ++#include <curses.h> + #endif + #ifdef XOAP + #include <libxml/parser.h> +@@ -117,15 +117,18 @@ + #include "freebsd.h" + #elif defined(__OpenBSD__) + #include "openbsd.h" ++#elif defined(__NetBSD__) ++#include "netbsd.h" + #endif + ++ + #if defined(__FreeBSD_kernel__) + #include <bsd/bsd.h> + #endif + + /* 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__)) + int apm_getinfo(int fd, apm_info_t aip); + char *get_apm_adapter(void); + char *get_apm_battery_life(void); +@@ -784,7 +787,7 @@ void generate_text_internal(char *p, int + OBJ(read_tcp) { + print_read_tcp(obj, p, p_max_size); + } +-#ifndef __OpenBSD__ ++#if !defined(__OpenBSD__) + OBJ(acpitemp) { + temp_print(p, p_max_size, get_acpi_temperature(obj->data.i), TEMP_CELSIUS); + } +@@ -799,7 +802,7 @@ void generate_text_internal(char *p, int + OBJ(freq_g) { + static int ok = 1; + if (ok) { +-#ifndef __OpenBSD__ ++#if !defined(__OpenBSD__) && !defined(__NetBSD__) + ok = get_freq(p, p_max_size, "%'.2f", 1000, + obj->data.i); + #else +@@ -846,7 +849,7 @@ void generate_text_internal(char *p, int + + #endif /* __linux__ */ + +-#ifndef __OpenBSD__ ++#if !defined(__OpenBSD__) + OBJ(acpifan) { + get_acpi_fan(p, p_max_size); + } +@@ -1015,13 +1018,11 @@ void generate_text_internal(char *p, int + get_powerbook_batt_info(p, p_max_size, obj->data.i); + } + #endif /* __linux__ */ +-#if (defined(__FreeBSD__) || defined(__linux__)) + OBJ(if_up) { + if (!interface_up(obj)) { + DO_JUMP; + } + } +-#endif + #ifdef __OpenBSD__ + OBJ(obsd_sensors_temp) { + print_obsd_sensors_temp(obj, p, p_max_size); +@@ -1899,7 +1900,7 @@ void generate_text_internal(char *p, int + } + #endif /* __linux__ */ + #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ +- || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) ++ || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) + OBJ(apm_adapter) { + char *msg; + +@@ -5680,6 +5681,13 @@ void initialisation(int argc, char **arg + } + pthread_mutex_init(&kvm_proc_mutex, NULL); + #endif ++#if defined(__NetBSD__) ++ if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL)) == NULL) ++ CRIT_ERR(NULL, NULL, "cannot read kvm"); ++ ++ /* open the sysmon fd */ ++ sysmon_open(); ++#endif + + while (1) { + int c = getopt_long(argc, argv, getopt_string, longopts, NULL); +@@ -5960,9 +5968,13 @@ int main(int argc, char **argv) + curl_global_cleanup(); + #endif + +-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) + kvm_close(kd); ++#ifndef __NetBSD__ + pthread_mutex_destroy(&kvm_proc_mutex); ++#else ++ sysmon_close(); ++#endif + #endif + + return 0; diff --git a/sysutils/conky/patches/patch-src_core.c b/sysutils/conky/patches/patch-src_core.c new file mode 100644 index 00000000000..5b86becf618 --- /dev/null +++ b/sysutils/conky/patches/patch-src_core.c @@ -0,0 +1,71 @@ +$NetBSD: patch-src_core.c,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Enable NetBSD as a suitable platform. + +--- src/core.c.orig 2012-05-03 21:08:27.000000000 +0000 ++++ src/core.c +@@ -65,7 +65,7 @@ + #include "top.h" + + #ifdef NCURSES +-#include <ncurses.h> ++#include <curses.h> + #endif + + /* check for OS and include appropriate headers */ +@@ -75,6 +75,8 @@ + #include "freebsd.h" + #elif defined(__OpenBSD__) + #include "openbsd.h" ++#elif defined(__NetBSD__) ++#include "netbsd.h" + #endif + + #include <string.h> +@@ -237,7 +239,7 @@ struct text_object *construct_text_objec + + #endif /* __linux__ */ + +-#ifndef __OpenBSD__ ++#if !defined(__OpenBSD__) + END OBJ(acpifan, 0) + END OBJ(battery, 0) + char bat[64]; +@@ -326,10 +328,8 @@ struct text_object *construct_text_objec + obj->data.i = PB_BATT_STATUS; + } + #endif /* __linux__ */ +-#if (defined(__FreeBSD__) || defined(__linux__)) + END OBJ_IF_ARG(if_up, 0, "if_up needs an argument") + parse_if_up_arg(obj, arg); +-#endif + #if defined(__OpenBSD__) + END OBJ_ARG(obsd_sensors_temp, 0, "obsd_sensors_temp: needs an argument") + parse_obsd_sensor(obj, arg); +@@ -860,7 +860,7 @@ struct text_object *construct_text_objec + END OBJ(gw_ip, &update_gateway_info) + #endif /* !__linux__ */ + #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ +- || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) ++ || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__)) + END OBJ(apm_adapter, 0) + END OBJ(apm_battery_life, 0) + END OBJ(apm_battery_time, 0) +@@ -1371,7 +1371,7 @@ void free_text_objects(struct text_objec + for (obj = root->prev; obj; obj = root->prev) { + root->prev = obj->prev; + switch (obj->type) { +-#ifndef __OpenBSD__ ++#if !defined(__OpenBSD__) + case OBJ_acpitemp: + close(data.i); + break; +@@ -1645,7 +1645,7 @@ void free_text_objects(struct text_objec + #endif /* HAVE_LUA */ + case OBJ_pre_exec: + break; +-#ifndef __OpenBSD__ ++#if !defined(__OpenBSD__) + case OBJ_battery: + free(data.s); + break; diff --git a/sysutils/conky/patches/patch-src_fs.c b/sysutils/conky/patches/patch-src_fs.c new file mode 100644 index 00000000000..e7cfb1e3718 --- /dev/null +++ b/sysutils/conky/patches/patch-src_fs.c @@ -0,0 +1,69 @@ +$NetBSD: patch-src_fs.c,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Check for sys/statvfs.h. + +--- src/fs.c.orig 2012-05-03 21:08:27.000000000 +0000 ++++ src/fs.c +@@ -44,6 +44,11 @@ + #include <sys/statfs.h> + #endif + ++/* NetBSD, Solaris */ ++#ifdef HAVE_SYS_STATVFS_H ++#include <sys/statvfs.h> ++#endif ++ + /* freebsd && netbsd */ + #ifdef HAVE_SYS_PARAM_H + #include <sys/param.h> +@@ -52,7 +57,7 @@ + #include <sys/mount.h> + #endif + +-#if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && !defined (__OpenBSD__) && !defined(__FreeBSD__) ++#if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && !defined (__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) + #include <mntent.h> + #endif + +@@ -118,6 +123,7 @@ struct fs_stat *prepare_fs_stat(const ch + + static void update_fs_stat(struct fs_stat *fs) + { ++#ifdef HAVE_SYS_STATFS_H + struct statfs64 s; + + if (statfs64(fs->path, &s) == 0) { +@@ -125,6 +131,14 @@ static void update_fs_stat(struct fs_sta + /* bfree (root) or bavail (non-roots) ? */ + fs->avail = (long long)s.f_bavail * s.f_bsize; + fs->free = (long long)s.f_bfree * s.f_bsize; ++#else ++ struct statvfs s; ++ ++ if (statvfs(fs->path, &s) == 0) { ++ fs->free = (long long)s.f_bfree * s.f_frsize; ++ fs->size = (long long)s.f_blocks * s.f_frsize; ++ fs->avail = (long long)s.f_bavail * s.f_frsize; ++#endif + get_fs_type(fs->path, fs->type); + } else { + NORM_ERR("statfs64 '%s': %s", fs->path, strerror(errno)); +@@ -138,10 +152,17 @@ static void update_fs_stat(struct fs_sta + void get_fs_type(const char *path, char *result) + { + +-#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(__FreeBSD__) || defined (__OpenBSD__) ++#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) + ++#ifdef HAVE_SYS_STATFS_H + struct statfs s; ++ + if (statfs(path, &s) == 0) { ++#else ++ struct statvfs s; ++ ++ if (statvfs(path, &s) == 0) { ++#endif + strncpy(result, s.f_fstypename, DEFAULT_TEXT_BUFFER_SIZE); + } else { + NORM_ERR("statfs '%s': %s", path, strerror(errno)); diff --git a/sysutils/conky/patches/patch-src_netbsd.c b/sysutils/conky/patches/patch-src_netbsd.c new file mode 100644 index 00000000000..6c1a072fca6 --- /dev/null +++ b/sysutils/conky/patches/patch-src_netbsd.c @@ -0,0 +1,1017 @@ +$NetBSD: patch-src_netbsd.c,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Many fixes and addons for conky to work on NetBSD. + +--- src/netbsd.c.orig 2012-05-03 21:08:27.000000000 +0000 ++++ src/netbsd.c +@@ -30,337 +30,795 @@ + + #include "netbsd.h" + #include "net_stat.h" ++#include "top.h" ++#include <sys/types.h> ++#include <sys/statvfs.h> ++#include <ifaddrs.h> + +-static kvm_t *kd = NULL; +-int kd_init = 0, nkd_init = 0; +-u_int32_t sensvalue; +-char errbuf[_POSIX2_LINE_MAX]; ++#define P_BOOL 0 ++#define P_UINT8 1 ++#define P_INT64 2 ++#define P_STRING 3 + +-static int init_kvm(void) ++typedef struct Devquery { ++ int type; ++ char *dev; ++ char *key; ++ char *row; ++} Devquery; ++ ++u_int32_t sensvalue; ++char errbuf[_POSIX2_LINE_MAX]; ++static short cpu_setup = 0; ++ ++int sysmon_fd; ++ ++inline void proc_find_top(struct process **cpu, struct process **mem); ++ ++int8_t envsys_get_val(Devquery, void *); ++ ++void ++prepare_update(void) + { +- if (kd_init) { +- return 0; +- } ++} + +- kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf); +- if (kd == NULL) { +- warnx("cannot kvm_openfiles: %s", errbuf); +- return -1; ++int ++update_uptime(void) ++{ ++ int mib[2] = { CTL_KERN, KERN_BOOTTIME }; ++ struct timeval boottime; ++ time_t now; ++ size_t size; ++ ++ size = sizeof(boottime); ++ ++ if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0) { ++ warn("sysctl kern.boottime failed"); ++ info.uptime = 0; ++ } else { ++ time(&now); ++ info.uptime = now - boottime.tv_sec; + } +- kd_init = 1; ++ + return 0; + } + +-static int swapmode(int *retavail, int *retfree) +-{ +- int n; +- struct swapent *sep; ++/* checks is mp is a mounted mountpoint */ ++int ++check_mount(char *mp) ++{ ++ int nbmount, i; ++ struct statvfs *mntbuf; ++ ++ nbmount = getmntinfo(&mntbuf, MNT_NOWAIT); ++ ++ for (i = 0; i < nbmount; i++) { ++ if (strcmp(mntbuf[i].f_mntonname, mp) == 0) { ++ return 1; ++ } ++ } + +- *retavail = 0; +- *retfree = 0; ++ return 0; ++} + +- n = swapctl(SWAP_NSWAP, 0, 0); ++/* mostly from vmstat.c */ ++int ++update_meminfo(void) ++{ ++ int mib[] = { CTL_VM, VM_UVMEXP2 }; ++ struct uvmexp_sysctl uvmexp; ++ size_t ssize; ++ ++ ssize = sizeof(uvmexp); ++ memset(&uvmexp, 0, ssize); ++ ++ info.mem = info.memmax = info.swap = info.swapfree = info.swapmax = 0; ++ info.buffers = info.cached = info.memfree = info.memeasyfree = 0; ++ info.bufmem = 0; + +- if (n < 1) { +- warn("could not get swap information"); ++ if (sysctl(mib, 2, &uvmexp, &ssize, NULL, 0) < 0) { ++ warn("sysctl vm.uvmexp2 failed"); + return 0; + } + +- sep = (struct swapent *) malloc(n * (sizeof(*sep))); ++ info.memmax = uvmexp.npages * uvmexp.pagesize / 1024; ++ info.memfree = uvmexp.inactive * uvmexp.pagesize / 1024; + +- if (sep == NULL) { +- warn("memory allocation failed"); ++ info.swapmax = uvmexp.swpages * uvmexp.pagesize / 1024; ++ info.swapfree = (uvmexp.swpages - uvmexp.swpginuse) * \ ++ uvmexp.pagesize / 1024; ++ ++ info.buffers = uvmexp.filepages * uvmexp.pagesize / 1024; ++ info.cached = uvmexp.execpages * uvmexp.pagesize / 1024; ++ ++ info.mem = info.memmax - info.memfree; ++ info.memeasyfree = info.memfree; ++ info.bufmem = info.cached + info.buffers; ++ info.swap = info.swapmax - info.swapfree; ++ ++ return 0; ++} ++ ++int ++update_net_stats(void) ++{ ++ struct net_stat *ns; ++ double delta; ++ long long r, t, last_recv, last_trans; ++ struct ifaddrs *ifap, *ifa; ++ struct if_data *ifd; ++ ++ /* get delta */ ++ delta = current_update_time - last_update_time; ++ if (delta <= 0.0001) { + return 0; + } + +- if (swapctl(SWAP_STATS, (void *) sep, n) < n) { +- warn("could not get swap stats"); ++ if (getifaddrs(&ifap) < 0) { + return 0; + } +- for (; n > 0; n--) { +- *retavail += (int) dbtob(sep[n - 1].se_nblks); +- *retfree += (int) dbtob(sep[n - 1].se_nblks - sep[n - 1].se_inuse); ++ ++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { ++ ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL); ++ ++ if (ifa->ifa_flags & IFF_UP) { ++ struct ifaddrs *iftmp; ++ ++ ns->up = 1; ++ last_recv = ns->recv; ++ last_trans = ns->trans; ++ ++ if (ifa->ifa_addr->sa_family != AF_LINK) { ++ continue; ++ } ++ ++ for (iftmp = ifa->ifa_next; ++ iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0; ++ iftmp = iftmp->ifa_next) { ++ if (iftmp->ifa_addr->sa_family == AF_INET) { ++ memcpy(&(ns->addr), iftmp->ifa_addr, ++ iftmp->ifa_addr->sa_len); ++ } ++ } ++ ++ ifd = (struct if_data *) ifa->ifa_data; ++ r = ifd->ifi_ibytes; ++ t = ifd->ifi_obytes; ++ ++ if (r < ns->last_read_recv) { ++ ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r; ++ } else { ++ ns->recv += (r - ns->last_read_recv); ++ } ++ ++ ns->last_read_recv = r; ++ ++ if (t < ns->last_read_trans) { ++ ns->trans += (long long) 4294967295U - ns->last_read_trans + t; ++ } else { ++ ns->trans += (t - ns->last_read_trans); ++ } ++ ++ ns->last_read_trans = t; ++ ++ /* calculate speeds */ ++ ns->recv_speed = (ns->recv - last_recv) / delta; ++ ns->trans_speed = (ns->trans - last_trans) / delta; ++ } else { ++ ns->up = 0; ++ } + } +- *retavail = (int) (*retavail / 1024); +- *retfree = (int) (*retfree / 1024); + +- return 1; +-} ++ freeifaddrs(ifap); + +-void prepare_update() +-{ ++ return 0; + } + +-void update_uptime() ++int ++update_total_processes(void) + { +- int mib[2] = { CTL_KERN, KERN_BOOTTIME }; +- struct timeval boottime; +- time_t now; +- int size = sizeof(boottime); ++ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL}; ++ size_t size; + +- if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) +- && (boottime.tv_sec != 0)) { +- time(&now); +- info.uptime = now - boottime.tv_sec; +- } else { +- warn("could not get uptime"); +- info.uptime = 0; ++ if (sysctl(mib, 3, NULL, &size, NULL, 0) < 0) { ++ warn("sysctl KERN_PROC_ALL failed"); ++ return 0; + } ++ ++ info.procs = (size / sizeof (struct kinfo_proc)); ++ ++ return 0; + } + +-int check_mount(char *s) ++int ++update_running_processes() + { +- /* stub */ ++ int n_processes, i, cnt = 0; ++ struct kinfo_proc2 *p; ++ ++ info.run_procs = 0; ++ ++ p = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), ++ &n_processes); ++ ++ for (i = 0; i < n_processes; i++) ++ if (p[i].p_stat == LSRUN || ++ p[i].p_stat == LSIDL || ++ p[i].p_stat == LSONPROC) ++ cnt++; ++ ++ info.run_procs = cnt; ++ + return 0; + } + +-void update_meminfo() ++struct cpu_load_struct { ++ unsigned long load[5]; ++}; ++ ++struct cpu_load_struct fresh = { ++ {0, 0, 0, 0, 0} ++}; ++ ++long *oldtotal = NULL, *oldused = NULL; ++ ++void ++get_cpu_count() + { +- int mib[] = { CTL_VM, VM_UVMEXP2 }; +- int total_pages, inactive_pages, free_pages; +- int swap_avail, swap_free; +- const int pagesize = getpagesize(); +- struct uvmexp_sysctl uvmexp; +- size_t size = sizeof(uvmexp); ++ static int mib[] = { CTL_HW, HW_NCPU }; ++ size_t len = sizeof(int); ++ int cpu_count; + +- if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) { +- warn("could not get memory info"); +- return; +- } ++ if (sysctl(mib, 2, &cpu_count, &len, NULL, 0) < 0) ++ cpu_count = 1; + +- total_pages = uvmexp.npages; +- free_pages = uvmexp.free; +- inactive_pages = uvmexp.inactive; ++ info.cpu_count = cpu_count; + +- info.memmax = (total_pages * pagesize) >> 10; +- info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10; +- info.memeasyfree = info.memfree = info.memmax - info.mem; ++ info.cpu_usage = malloc(info.cpu_count * sizeof(float)); + +- if (swapmode(&swap_avail, &swap_free) >= 0) { +- info.swapmax = swap_avail; +- info.swap = (swap_avail - swap_free); +- info.swapfree = swap_free; +- } ++ if (info.cpu_usage == NULL) ++ warn("malloc"); + } + +-void update_net_stats() ++struct cpu_info { ++ long oldtotal; ++ long oldused; ++}; ++ ++int ++update_cpu_usage(void) + { +- int i; +- double delta; +- struct ifnet ifnet; +- struct ifnet_head ifhead; /* interfaces are in a tail queue */ +- u_long ifnetaddr; +- static struct nlist namelist[] = { +- { "_ifnet" }, +- { NULL } +- }; +- static kvm_t *nkd; +- +- if (!nkd_init) { +- nkd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); +- if (nkd == NULL) { +- warnx("cannot kvm_openfiles: %s", errbuf); +- warnx("maybe you need to setgid kmem this program?"); +- return; +- } else if (kvm_nlist(nkd, namelist) != 0) { +- warn("cannot kvm_nlist"); +- return; +- } else { +- nkd_init = 1; +- } ++ /* mostly taken from freebsd.c */ ++ int i, j = 0; ++ uint64_t used, total; ++ uint64_t *cp_time = NULL; ++ size_t cp_len; ++ static struct cpu_info *cpu = NULL; ++ unsigned int malloc_cpu_size = 0; ++ extern void* global_cpu; ++ ++ /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */ ++ if ((cpu_setup == 0) || (!info.cpu_usage)) { ++ get_cpu_count(); ++ cpu_setup = 1; + } + +- if (kvm_read(nkd, (u_long) namelist[0].n_value, (void *) &ifhead, +- sizeof(ifhead)) < 0) { +- warn("cannot kvm_read"); +- return; ++ if (!global_cpu) { ++ malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info); ++ cpu = malloc(malloc_cpu_size); ++ memset(cpu, 0, malloc_cpu_size); ++ global_cpu = cpu; + } + +- /* get delta */ +- delta = current_update_time - last_update_time; +- if (delta <= 0.0001) { +- return; ++ /* cpu[0] is overall stats, get it from separate sysctl */ ++ cp_len = CPUSTATES * sizeof(uint64_t); ++ cp_time = malloc(cp_len); ++ ++ if (sysctlbyname("kern.cp_time", cp_time, &cp_len, NULL, 0) < 0) { ++ fprintf(stderr, "Cannot get kern.cp_time\n"); + } + +- for (i = 0, ifnetaddr = (u_long) ifhead.tqh_first; +- ifnet.if_list.tqe_next && i < 16; +- ifnetaddr = (u_long) ifnet.if_list.tqe_next, i++) { +- +- struct net_stat *ns; +- long long last_recv, last_trans; +- +- kvm_read(nkd, (u_long) ifnetaddr, (void *) &ifnet, sizeof(ifnet)); +- ns = get_net_stat(ifnet.if_xname, NULL, NULL); +- ns->up = 1; +- last_recv = ns->recv; +- last_trans = ns->trans; +- +- if (ifnet.if_ibytes < ns->last_read_recv) { +- ns->recv += ((long long) 4294967295U - ns->last_read_recv) + +- ifnet.if_ibytes; +- } else { +- ns->recv += (ifnet.if_ibytes - ns->last_read_recv); +- } ++ total = 0; ++ for (j = 0; j < CPUSTATES; j++) ++ total += cp_time[j]; + +- ns->last_read_recv = ifnet.if_ibytes; ++ used = total - cp_time[CP_IDLE]; + +- if (ifnet.if_obytes < ns->last_read_trans) { +- ns->trans += ((long long) 4294967295U - ns->last_read_trans) + +- ifnet.if_obytes; ++ if ((total - cpu[0].oldtotal) != 0) { ++ info.cpu_usage[0] = ((double) (used - cpu[0].oldused)) / ++ (double) (total - cpu[0].oldtotal); ++ } else { ++ info.cpu_usage[0] = 0; ++ } ++ ++ cpu[0].oldused = used; ++ cpu[0].oldtotal = total; ++ ++ free(cp_time); ++ ++ /* per-core stats */ ++ cp_len = CPUSTATES * sizeof(uint64_t) * info.cpu_count; ++ cp_time = malloc(cp_len); ++ ++ /* on e.g. i386 SMP we may have more values than actual cpus; this will just drop extra values */ ++ if (sysctlbyname("kern.cp_time", cp_time, &cp_len, NULL, 0) < 0 && errno != ENOMEM) { ++ fprintf(stderr, "Cannot get kern.cp_time SMP\n"); ++ } ++ ++ for (i = 0; i < info.cpu_count; i++) ++ { ++ total = 0; ++ for (j = 0; j < CPUSTATES; j++) ++ total += cp_time[i*CPUSTATES + j]; ++ ++ used = total - cp_time[i*CPUSTATES + CP_IDLE]; ++ ++ if ((total - cpu[i+1].oldtotal) != 0) { ++ info.cpu_usage[i+1] = ((double) (used - cpu[i+1].oldused)) / ++ (double) (total - cpu[i+1].oldtotal); + } else { +- ns->trans += (ifnet.if_obytes - ns->last_read_trans); ++ info.cpu_usage[i+1] = 0; + } + +- ns->last_read_trans = ifnet.if_obytes; ++ cpu[i+1].oldused = used; ++ cpu[i+1].oldtotal = total; ++ } ++ ++ free(cp_time); ++ return 0; ++} ++ ++int update_load_average(void) ++{ ++ double v[3]; ++ ++ getloadavg(v, 3); ++ ++ info.loadavg[0] = (float) v[0]; ++ info.loadavg[1] = (float) v[1]; ++ info.loadavg[2] = (float) v[2]; ++ ++ return 0; ++} ++ ++int open_acpi_temperature(const char *name) ++{ ++ (void)name; /* useless on NetBSD */ ++ return -1; ++} ++ ++int get_entropy_avail(unsigned int *val) ++{ ++ return 1; ++} ++ ++int get_entropy_poolsize(unsigned int *val) ++{ ++ return 1; ++} + +- ns->recv += (ifnet.if_ibytes - ns->last_read_recv); +- ns->last_read_recv = ifnet.if_ibytes; +- ns->trans += (ifnet.if_obytes - ns->last_read_trans); +- ns->last_read_trans = ifnet.if_obytes; ++/* void */ ++char ++get_freq(char *p_client_buffer, size_t client_buffer_size, ++ const char *p_format, int divisor, unsigned int cpu) ++{ ++ int freq = cpu; + +- ns->recv_speed = (ns->recv - last_recv) / delta; +- ns->trans_speed = (ns->trans - last_trans) / delta; ++ if (!p_client_buffer || client_buffer_size <= 0 || !p_format ++ || divisor <= 0) { ++ return 0; + } ++ ++ size_t size = sizeof(freq); ++ ++ if (sysctlbyname("machdep.est.frequency.current", ++ NULL, &size, NULL, 0) == 0) { ++ sysctlbyname("machdep.est.frequency.current", &freq, &size, NULL, 0); ++ snprintf(p_client_buffer, client_buffer_size, p_format, ++ (float) freq / divisor); ++ } else if (sysctlbyname("machdep.tsc_freq", NULL, &size, NULL, 0) == 0) { ++ sysctlbyname("machdep.tsc_freq", &freq, &size, NULL, 0); ++ snprintf(p_client_buffer, client_buffer_size, p_format, ++ (float) freq / (1000000 * divisor)); ++ } else ++ snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f); ++ ++ return 1; + } + +-void update_total_processes() ++void update_diskio() + { +- /* It's easier to use kvm here than sysctl */ ++ return; /* XXX: implement? hifi: not sure how */ ++} + +- int n_processes; ++int update_top() ++{ ++ proc_find_top(info.cpu, info.memu); + +- info.procs = 0; ++ return 0; ++} + +- if (init_kvm() < 0) { +- return; +- } else { +- kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), +- &n_processes); ++int comparecpu(const void *a, const void *b) ++{ ++ if (((struct process *) a)->amount > ((struct process *) b)->amount) { ++ return -1; ++ } ++ if (((struct process *) a)->amount < ((struct process *) b)->amount) { ++ return 1; + } + +- info.procs = n_processes; ++ return 0; + } + +-void update_running_processes() ++int comparemem(const void *a, const void *b) + { +- struct kinfo_proc2 *p; +- int n_processes; +- int i, cnt = 0; ++ if (((struct process *) a)->rss > ((struct process *) b)->rss) { ++ return -1; ++ } + +- info.run_procs = 0; ++ if (((struct process *) a)->rss < ((struct process *) b)->rss) { ++ return 1; ++ } + +- if (init_kvm() < 0) { +- return; +- } else { +- p = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2), +- &n_processes); +- for (i = 0; i < n_processes; i++) { +- if (p[i].p_stat == LSRUN || p[i].p_stat == LSIDL +- || p[i].p_stat == LSONPROC) { +- cnt++; ++ return 0; ++} ++ ++inline void proc_find_top(struct process **cpu, struct process **mem) ++{ ++ struct kinfo_proc2 *p; ++ int n_processes; ++ int i, j = 0; ++ struct process *processes; ++ int mib[2]; ++ ++ u_int total_pages; ++ int64_t usermem; ++ int pagesize = getpagesize(); ++ ++ /* we get total pages count again to be sure it is up to date */ ++ mib[0] = CTL_HW; ++ mib[1] = HW_USERMEM64; ++ size_t size = sizeof(usermem); ++ ++ if (sysctl(mib, 2, &usermem, &size, NULL, 0) == -1) { ++ err(EXIT_FAILURE, "error reading usermem"); ++ } ++ ++ /* translate bytes into page count */ ++ total_pages = usermem / pagesize; ++ ++ int max_size = sizeof(struct kinfo_proc2); ++ ++ p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes); ++ processes = malloc(n_processes * sizeof(struct process)); ++ ++ for (i = 0; i < n_processes; i++) { ++ if (!((p[i].p_flag & P_SYSTEM)) && p[i].p_comm != NULL) { ++ processes[j].pid = p[i].p_pid; ++ processes[j].name = strndup(p[i].p_comm, text_buffer_size); ++ processes[j].amount = 100.0 * p[i].p_pctcpu / FSCALE; ++ processes[j].rss = p[i].p_vm_rssize * pagesize; ++ processes[j].vsize = p[i].p_vm_vsize; ++ j++; + } +- } +- } ++ } + +- info.run_procs = cnt; ++ qsort(processes, j - 1, sizeof(struct process), comparemem); ++ for (i = 0; i < 10; i++) { ++ struct process *tmp, *ttmp; ++ ++ tmp = malloc(sizeof(struct process)); ++ memcpy(tmp, &processes[i], sizeof(struct process)); ++ tmp->name = strndup(processes[i].name, text_buffer_size); ++ ++ ttmp = mem[i]; ++ mem[i] = tmp; ++ if (ttmp != NULL) { ++ free(ttmp->name); ++ free(ttmp); ++ } ++ } ++ ++ qsort(processes, j - 1, sizeof(struct process), comparecpu); ++ for (i = 0; i < 10; i++) { ++ struct process *tmp, *ttmp; ++ ++ tmp = malloc(sizeof(struct process)); ++ memcpy(tmp, &processes[i], sizeof(struct process)); ++ tmp->name = strndup(processes[i].name, text_buffer_size); ++ ++ ttmp = cpu[i]; ++ cpu[i] = tmp; ++ if (ttmp != NULL) { ++ free(ttmp->name); ++ free(ttmp); ++ } ++ } ++ ++ for (i = 0; i < j; i++) { ++ free(processes[i].name); ++ } ++ free(processes); + } + +-struct cpu_load_struct { +- unsigned long load[5]; +-}; ++double ++get_acpi_temperature(int fd) ++{ ++ Devquery dq_tz = { P_INT64, "acpitz0", "temperature", "cur-value" }; ++ int64_t temp; + +-struct cpu_load_struct fresh = { +- {0, 0, 0, 0, 0} +-}; ++ (void)fd; + +-long cpu_used, oldtotal, oldused; ++ if (envsys_get_val(dq_tz, (void *)&temp) < 0) ++ return 0.0; + +-void update_cpu_usage() ++ return (temp / 1000000.0) - 273.15; ++} ++ ++void ++get_bat_life(char *bat, char *buf) + { +- long used, total; +- static u_int64_t cp_time[CPUSTATES]; +- size_t len = sizeof(cp_time); ++ char row[32]; ++ int64_t cur_charge, max_charge; ++ Devquery dq_charge = { P_INT64, bat, "charge", NULL}; + +- info.cpu_usage = 0; ++ strcpy(row, "max-value"); ++ dq_charge.row = &row[0]; + +- if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) { +- warn("cannot get kern.cp_time"); ++ if (envsys_get_val(dq_charge, (void *)&max_charge) < 0) { ++ /* did not get any information from envsys */ ++ strcpy(buf, "N/A"); ++ return; + } + +- fresh.load[0] = cp_time[CP_USER]; +- fresh.load[1] = cp_time[CP_NICE]; +- fresh.load[2] = cp_time[CP_SYS]; +- fresh.load[3] = cp_time[CP_IDLE]; +- fresh.load[4] = cp_time[CP_IDLE]; +- +- used = fresh.load[0] + fresh.load[1] + fresh.load[2]; +- total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3]; ++ strcpy(row, "cur-value"); ++ dq_charge.row = &row[0]; + +- if ((total - oldtotal) != 0) { +- info.cpu_usage = ((double) (used - oldused)) / +- (double) (total - oldtotal); +- } else { +- info.cpu_usage = 0; ++ if (envsys_get_val(dq_charge, (void *)&cur_charge) < 0) { ++ /* did not get any information from envsys */ ++ strcpy(buf, "N/A"); ++ return; + } + +- oldused = used; +- oldtotal = total; ++ snprintf(buf, 8, "%d%%", (int)(((float) cur_charge / max_charge) * 100)); + } + +-void update_load_average() ++int ++get_bat_state(char *bat, char *buf) + { +- double v[3]; ++ bool connected = false, charging = false; ++ char curcap[8]; ++ Devquery dq_ac = { P_BOOL, "acpiacad0", "connected", "cur-value" }; ++ Devquery dq_charging = { P_BOOL, bat, "charging", "cur-value" }; + +- getloadavg(v, 3); ++ /* get AC state */ ++ if (envsys_get_val(dq_ac, (void *)&connected) < 0) { ++ /* did not get any information from envsys */ ++ strcpy(buf, "N/A"); ++ return 0; ++ } + +- info.loadavg[0] = (float) v[0]; +- info.loadavg[1] = (float) v[1]; +- info.loadavg[2] = (float) v[2]; ++ /* used by get_acpi_ac_adapter */ ++ if (bat == NULL) ++ return connected; ++ ++ /* is the battery charging ? */ ++ (void)envsys_get_val(dq_charging, (void *)&charging); ++ ++ /* get its current cap */ ++ get_bat_life(bat, &curcap[0]); ++ ++ if (connected) ++ if (charging) ++ snprintf(buf, 256, "charging (%s)", curcap); ++ else ++ strcpy(buf, "on-line"); ++ else ++ snprintf(buf, 256, "off-line (%s)", curcap); ++ ++ return 0; + } + +-double get_acpi_temperature(int fd) ++void ++get_bat_time(char *bat, char *buf, unsigned int n) + { +- return -1; ++ int64_t charge, discharge; ++ int hours, minutes; ++ Devquery dq_discharge = { P_INT64, bat, "discharge rate", ++ "cur-value"}; ++ Devquery dq_charge = { P_INT64, bat, "charge", "cur-value"}; ++ ++ if ((envsys_get_val(dq_discharge, (void *)&discharge) < 0) || !discharge) { ++ strcpy(buf, "N/A"); ++ return; ++ } ++ if (envsys_get_val(dq_charge, (void *)&charge) < 0) { ++ strcpy(buf, "N/A"); ++ return; ++ } ++ ++ hours = (int)((float) charge / discharge); ++ minutes = (int)((((float) charge / discharge) - hours) * 60); ++ ++ snprintf(buf, n, "%d:%02d", hours, minutes); + } + +-void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) ++void ++get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) + { ++ int bat_num; ++ char b_name[32]; ++ ++ sscanf(bat, "BAT%d", &bat_num); ++ sprintf(b_name, "acpibat%d", bat_num); ++ ++ switch (item) { ++ case BATTERY_TIME: ++ get_bat_time(b_name, buf, n); ++ break; ++ case BATTERY_STATUS: ++ get_bat_state(b_name, buf); ++ break; ++ default: ++ fprintf(stderr, "Unknown requested battery stat %d\n", item); ++ } + } + +-int open_acpi_temperature(const char *name) ++void ++get_battery_short_status(char *buffer, unsigned int n, const char *bat) + { +- return -1; ++ get_battery_stuff(buffer, n, bat, BATTERY_STATUS); ++ if (0 == strncmp("charging", buffer, 8)) { ++ buffer[0] = 'C'; ++ memmove(buffer + 1, buffer + 8, n - 8); ++ } else if (0 == strncmp("off-line", buffer, 11)) { ++ buffer[0] = 'D'; ++ memmove(buffer + 1, buffer + 11, n - 11); ++ } else if (0 == strncmp("on-line", buffer, 12)) { ++ buffer[0] = 'A'; ++ memmove(buffer + 1, buffer + 12, n - 12); ++ } + } + +-void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter) ++void ++get_acpi_ac_adapter(char *p_client_buffer, ++ size_t client_buffer_size, const char *adapter) + { +- (void) adapter; // only linux uses this ++ int connected; ++ ++ (void)adapter; // only linux uses this + + if (!p_client_buffer || client_buffer_size <= 0) { + return; + } + +- /* not implemented */ +- memset(p_client_buffer, 0, client_buffer_size); ++ connected = get_bat_state(NULL, NULL); ++ ++ if (connected) { ++ strncpy(p_client_buffer, "Running on AC Power", client_buffer_size); ++ } else { ++ strncpy(p_client_buffer, "Running on battery", client_buffer_size); ++ } ++} ++ ++int ++get_battery_perct(const char *bat) ++{ ++ int64_t designcap, lastfulcap; ++ int bat_num, batperct; ++ char b_name[32]; ++ char *lastfulcap_prop = "last full cap"; ++ char *designcap_prop = "design cap"; ++ Devquery dq_cap = { P_INT64, NULL, NULL, NULL}; ++ ++ sscanf(bat, "BAT%d", &bat_num); ++ sprintf(b_name, "acpibat%d", bat_num); ++ ++ dq_cap.dev = &b_name[0]; ++ dq_cap.key = designcap_prop; ++ ++ if (envsys_get_val(dq_cap, (void *)&designcap) < 0) ++ designcap = 0; ++ ++ dq_cap.key = lastfulcap_prop; ++ ++ if (envsys_get_val(dq_cap, (void *)&lastfulcap) < 0) ++ lastfulcap = 0; ++ ++ batperct = (designcap > 0 && lastfulcap > 0) ? ++ (int) (((float) lastfulcap / designcap) * 100) : 0; ++ ++ return batperct > 100 ? 100 : batperct; ++} ++ ++int ++get_battery_perct_bar(const char *bat) ++{ ++ int batperct = get_battery_perct(bat); ++ return (int)(batperct * 2.56 - 1); + } + +-/* char *get_acpi_fan() */ + void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) + { +- if (!p_client_buffer || client_buffer_size <= 0) { +- return; ++ /* not implemented */ ++ if (p_client_buffer && client_buffer_size > 0) { ++ memset(p_client_buffer, 0, client_buffer_size); + } ++} + +- /* not implemented */ +- memset(p_client_buffer, 0, client_buffer_size); ++/* ++ * Here comes the mighty envsys backend ++ */ ++void ++sysmon_open() ++{ ++ sysmon_fd = open(_DEV_SYSMON, O_RDONLY); + } + +-int get_entropy_avail(unsigned int *val) ++void ++sysmon_close() + { +- return 1; ++ if (sysmon_fd > -1) ++ close(sysmon_fd); + } + +-int get_entropy_poolsize(unsigned int *val) ++int8_t ++envsys_get_val(Devquery dq, void *val) + { +- return 1; ++ char *descr; ++ const char *cval; ++ prop_dictionary_t dict; ++ prop_object_t device; ++ prop_object_iterator_t iter; ++ prop_object_t obj; ++ bool rc = false; ++ ++ if (sysmon_fd < 0) ++ return -1; ++ ++ if (prop_dictionary_recv_ioctl(sysmon_fd, ENVSYS_GETDICTIONARY, &dict) ++ != 0) ++ return -1; ++ ++ if ((device = prop_dictionary_get(dict, dq.dev)) == NULL) ++ return -1; ++ ++ iter = prop_array_iterator(device); ++ ++ while((obj = prop_object_iterator_next(iter))) { ++ descr = (char *)prop_string_cstring_nocopy(prop_dictionary_get(obj, ++ "description")); ++ if (descr != NULL && *descr) { ++ if(strcmp(descr, dq.key) == 0) { ++ switch(dq.type) { ++ case P_BOOL: ++ rc = prop_dictionary_get_bool(obj, ++ dq.row, (bool *)val); ++ case P_UINT8: ++ rc = prop_dictionary_get_uint8(obj, ++ dq.row, (uint8_t *)val); ++ break; ++ case P_INT64: ++ rc = prop_dictionary_get_int64(obj, dq.row, ++ (int64_t *)val); ++ break; ++ case P_STRING: ++ rc = prop_dictionary_get_cstring_nocopy(obj, ++ dq.row, &cval); ++ val = (void *)cval; ++ break; ++ } ++ } ++ } ++ } ++ ++ prop_object_iterator_release(iter); ++ prop_object_release(dict); ++ ++ if (rc == false) { ++ val = NULL; ++ return -1; ++ } ++ ++ return 0; + } diff --git a/sysutils/conky/patches/patch-src_netbsd.h b/sysutils/conky/patches/patch-src_netbsd.h new file mode 100644 index 00000000000..fddf011dc56 --- /dev/null +++ b/sysutils/conky/patches/patch-src_netbsd.h @@ -0,0 +1,36 @@ +$NetBSD: patch-src_netbsd.h,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Many fixes and addons for conky to work on NetBSD. + +--- src/netbsd.h.orig 2010-03-25 17:42:39.000000000 +0000 ++++ src/netbsd.h +@@ -12,6 +12,8 @@ + #include <kvm.h> + #include <nlist.h> + ++#include <pthread.h> ++ + #include <sys/time.h> + #include <sys/sysctl.h> + #include <sys/types.h> +@@ -27,10 +29,20 @@ + + #include <machine/param.h> + ++#include <prop/proplib.h> ++ + #include "conky.h" + #include "common.h" + ++#define _DEV_SYSMON "/dev/sysmon" ++ + int get_entropy_avail(unsigned int *); + int get_entropy_poolsize(unsigned int *); + ++void sysmon_open(void); ++void sysmon_close(void); ++ ++kvm_t *kd; ++extern int sysmon_fd; ++ + #endif /*NETBSD_H_*/ diff --git a/sysutils/conky/patches/patch-src_text__object.h b/sysutils/conky/patches/patch-src_text__object.h new file mode 100644 index 00000000000..fdaf7ebcbc3 --- /dev/null +++ b/sysutils/conky/patches/patch-src_text__object.h @@ -0,0 +1,25 @@ +$NetBSD: patch-src_text__object.h,v 1.1.1.1 2012/05/13 08:42:20 imil Exp $ + +Enable NetBSD as a suitable platform. + +--- src/text_object.h.orig 2012-05-03 21:08:27.000000000 +0000 ++++ src/text_object.h +@@ -166,9 +166,7 @@ enum text_object_type { + OBJ_wireless_link_qual_perc, + OBJ_wireless_link_bar, + #endif /* __linux__ */ +-#if defined(__FreeBSD__) || defined(__linux__) + OBJ_if_up, +-#endif + OBJ_if_empty, + OBJ_if_match, + OBJ_if_existing, +@@ -311,7 +309,7 @@ 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__)) + OBJ_apm_adapter, + OBJ_apm_battery_time, + OBJ_apm_battery_life, |