pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Add conky-1.11.6
Module Name: pkgsrc-wip
Committed By: nia <nia%netbsd.org@localhost>
Pushed By: nee
Date: Thu Aug 27 10:25:52 2020 +0100
Changeset: 95c97ce86b132730e0873ce9eb0c410194b667f8
Modified Files:
Makefile
Added Files:
conky/DESCR
conky/Makefile
conky/PLIST
conky/TODO
conky/distinfo
conky/patches/patch-CMakeLists.txt
conky/patches/patch-cmake_Conky.cmake
conky/patches/patch-cmake_ConkyPlatformChecks.cmake
conky/patches/patch-src_entropy.cc
conky/patches/patch-src_fs.cc
conky/patches/patch-src_netbsd.cc
conky/patches/patch-src_netbsd.h
Log Message:
Add conky-1.11.6
This is a half finished attempt to forward-port the NetBSD patches
to a new version.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=95c97ce86b132730e0873ce9eb0c410194b667f8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 +
conky/DESCR | 16 +
conky/Makefile | 47 ++
conky/PLIST | 7 +
conky/TODO | 4 +
conky/distinfo | 13 +
conky/patches/patch-CMakeLists.txt | 31 ++
conky/patches/patch-cmake_Conky.cmake | 35 ++
.../patches/patch-cmake_ConkyPlatformChecks.cmake | 32 ++
conky/patches/patch-src_entropy.cc | 15 +
conky/patches/patch-src_fs.cc | 55 ++
conky/patches/patch-src_netbsd.cc | 594 +++++++++++++++++++++
conky/patches/patch-src_netbsd.h | 21 +
13 files changed, 871 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index 2c8d1b1b37..96a38c204b 100644
--- a/Makefile
+++ b/Makefile
@@ -517,6 +517,7 @@ SUBDIR+= compiz-boxmenu
SUBDIR+= complexity
SUBDIR+= concorde
SUBDIR+= conkeror
+SUBDIR+= conky
SUBDIR+= consul
SUBDIR+= contacts
SUBDIR+= converttomp3
diff --git a/conky/DESCR b/conky/DESCR
new file mode 100644
index 0000000000..f28e85d0ca
--- /dev/null
+++ b/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/conky/Makefile b/conky/Makefile
new file mode 100644
index 0000000000..571546ef30
--- /dev/null
+++ b/conky/Makefile
@@ -0,0 +1,47 @@
+# $NetBSD: Makefile,v 1.48 2020/08/17 20:20:03 leot Exp $
+#
+
+DISTNAME= conky-1.11.6
+CATEGORIES= sysutils
+MASTER_SITES= ${MASTER_SITE_GITHUB:=brndnmtthws/}
+GITHUB_TAG= v${PKGVERSION_NOREV}
+
+MAINTAINER= imil%NetBSD.org@localhost
+HOMEPAGE= https://github.com/brndnmtthws/conky/wiki
+COMMENT= Free, light-weight system monitor for X
+LICENSE= gnu-gpl-v3
+
+USE_CMAKE= yes
+USE_TOOLS+= pkg-config
+USE_LANGUAGES= c c++
+
+CMAKE_ARGS+= -DRELEASE=ON
+
+# XXX: investigate fixing this with NetBSD curses
+CMAKE_ARGS+= -DBUILD_NCURSES=OFF
+
+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
+
+LUA_VERSIONS_ACCEPTED= 53 52
+
+INSTALLATION_DIRS+= ${EGDIR}
+
+post-install:
+ ${MV} ${DESTDIR}${PREFIX}/share/doc/conky-*/*.conf ${DESTDIR}${PREFIX}/${EGDIR}
+
+.include "../../graphics/hicolor-icon-theme/buildlink3.mk"
+.include "../../lang/lua/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 "../../sysutils/desktop-file-utils/buildlink3.mk"
+.include "../../textproc/libxml2/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/conky/PLIST b/conky/PLIST
new file mode 100644
index 0000000000..1b2077dd3b
--- /dev/null
+++ b/conky/PLIST
@@ -0,0 +1,7 @@
+@comment $NetBSD$
+bin/conky
+share/applications/conky.desktop
+share/doc/${PKGNAME}/convert.lua
+share/examples/conky/conky.conf
+share/examples/conky/conky_no_x11.conf
+share/icons/hicolor/scalable/apps/conky-logomark-violet.svg
diff --git a/conky/TODO b/conky/TODO
new file mode 100644
index 0000000000..7544ad52db
--- /dev/null
+++ b/conky/TODO
@@ -0,0 +1,4 @@
+- Fix curses support on NetBSD.
+- Forwardport the NetBSD battery bits from sysutils/conky
+- Look into default config paths...
+- Build documentation?
diff --git a/conky/distinfo b/conky/distinfo
new file mode 100644
index 0000000000..ee4d3157d1
--- /dev/null
+++ b/conky/distinfo
@@ -0,0 +1,13 @@
+$NetBSD: distinfo,v 1.7 2017/06/30 00:23:03 kamil Exp $
+
+SHA1 (conky-1.11.6.tar.gz) = bf4b3dfe895f400b27a57ddc14964d231dc98005
+RMD160 (conky-1.11.6.tar.gz) = e6be6ed0546b530c451638b7647712f3c4462dc6
+SHA512 (conky-1.11.6.tar.gz) = f7bffcef33680d61d0171ba50b29ddda011c1c1989fc847cd4b5b60d46bed4772294eec34fd27c4d642a9c03e3cedaa31855ffc0f3b60791f4bed14ffdf7490a
+Size (conky-1.11.6.tar.gz) = 2402216 bytes
+SHA1 (patch-CMakeLists.txt) = f3133348d67e62230ad3e6c001c14c4136d43d51
+SHA1 (patch-cmake_Conky.cmake) = b17fdb4dfa968aa4437eb26e68efa5fc308c759d
+SHA1 (patch-cmake_ConkyPlatformChecks.cmake) = 14d9dad017d4f7e45f883288ffa14146ce09d853
+SHA1 (patch-src_entropy.cc) = be1ac9bddde941d698f2e66dfef05d668eda3216
+SHA1 (patch-src_fs.cc) = 02fd3433c353dd883cc9ea2d4593279aee6e22c8
+SHA1 (patch-src_netbsd.cc) = c8ddc81a9abaf30a30ca44de0d48dd22d3ebf744
+SHA1 (patch-src_netbsd.h) = 7c7df63b6ffac9e8ad23f5371b8c3d25ff733ab2
diff --git a/conky/patches/patch-CMakeLists.txt b/conky/patches/patch-CMakeLists.txt
new file mode 100644
index 0000000000..7e0f61118d
--- /dev/null
+++ b/conky/patches/patch-CMakeLists.txt
@@ -0,0 +1,31 @@
+$NetBSD$
+
+- Don't use CMAKE_MODULE_PATH directly so pkgsrc can append it with
+ multiple paths.
+- Install freedesktop.org files unconditionally.
+
+--- CMakeLists.txt.orig 2020-07-27 12:01:52.000000000 +0000
++++ CMakeLists.txt
+@@ -38,8 +38,8 @@ include(ConkyPlatformChecks)
+ include(ConkyCPackSetup)
+
+ # setup our configuration headers
+-configure_file(${CMAKE_MODULE_PATH}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
+-configure_file(${CMAKE_MODULE_PATH}/build.h.in ${CMAKE_BINARY_DIR}/build.h)
++configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in ${CMAKE_BINARY_DIR}/config.h)
++configure_file(${CMAKE_SOURCE_DIR}/cmake/build.h.in ${CMAKE_BINARY_DIR}/build.h)
+
+ set(conky_sources ${CMAKE_BINARY_DIR}/config.h ${CMAKE_BINARY_DIR}/build.h)
+
+@@ -94,11 +94,9 @@ if(BUILD_DOCS)
+ install(FILES ${MAN_FILES} DESTINATION ${MAN_PATH})
+ endif(BUILD_DOCS)
+
+-if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ install(FILES conky.desktop DESTINATION share/applications)
+ install(FILES logo/conky-logomark-violet.svg
+ DESTINATION share/icons/hicolor/scalable/apps)
+-endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+ if(CHECK_CODE_QUALITY)
+ find_package(ClangTidy)
diff --git a/conky/patches/patch-cmake_Conky.cmake b/conky/patches/patch-cmake_Conky.cmake
new file mode 100644
index 0000000000..1b10dc9803
--- /dev/null
+++ b/conky/patches/patch-cmake_Conky.cmake
@@ -0,0 +1,35 @@
+$NetBSD$
+
+Add missing entries for NetBSD.
+
+--- cmake/Conky.cmake.orig 2020-07-27 12:01:52.000000000 +0000
++++ cmake/Conky.cmake
+@@ -55,6 +55,7 @@ endif(CMAKE_SYSTEM_NAME MATCHES "Darwin"
+
+ if(NOT OS_LINUX
+ AND NOT OS_FREEBSD
++ AND NOT OS_NETBSD
+ AND NOT OS_OPENBSD
+ AND NOT OS_DRAGONFLY
+ AND NOT OS_SOLARIS
+@@ -71,6 +72,9 @@ endif(NOT
+ OS_FREEBSD
+ AND
+ NOT
++ OS_NETBSD
++ AND
++ NOT
+ OS_OPENBSD
+ AND
+ NOT
+@@ -113,6 +117,10 @@ if(OS_FREEBSD)
+ )
+ endif(OS_FREEBSD)
+
++if(OS_NETBSD)
++ add_definitions(-D_NETBSD_SOURCE -D_XOPEN_SOURCE=700 -D_KMEMUSER)
++endif(OS_NETBSD)
++
+ if(OS_DRAGONFLY)
+ set(conky_libs ${conky_libs} -L/usr/pkg/lib)
+ set(conky_includes ${conky_includes} -I/usr/pkg/include)
diff --git a/conky/patches/patch-cmake_ConkyPlatformChecks.cmake b/conky/patches/patch-cmake_ConkyPlatformChecks.cmake
new file mode 100644
index 0000000000..0069a592b1
--- /dev/null
+++ b/conky/patches/patch-cmake_ConkyPlatformChecks.cmake
@@ -0,0 +1,32 @@
+$NetBSD$
+
+Add missing entries for NetBSD.
+
+--- cmake/ConkyPlatformChecks.cmake.orig 2020-07-27 12:01:52.000000000 +0000
++++ cmake/ConkyPlatformChecks.cmake
+@@ -83,6 +83,7 @@ endif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+
+ if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+ set(OS_NETBSD true)
++ set(conky_libs ${conky_libs} -lkvm -lossaudio -lprop)
+ endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+
+ if(CMAKE_SYSTEM_NAME MATCHES "Haiku")
+@@ -96,6 +97,7 @@ endif(CMAKE_SYSTEM_NAME MATCHES "Darwin"
+
+ if(NOT OS_LINUX
+ AND NOT OS_FREEBSD
++ AND NOT OS_NETBSD
+ AND NOT OS_OPENBSD
+ AND NOT OS_DRAGONFLY
+ AND NOT OS_SOLARIS
+@@ -112,6 +114,9 @@ endif(NOT
+ OS_FREEBSD
+ AND
+ NOT
++ OS_NETBSD
++ AND
++ NOT
+ OS_OPENBSD
+ AND
+ NOT
diff --git a/conky/patches/patch-src_entropy.cc b/conky/patches/patch-src_entropy.cc
new file mode 100644
index 0000000000..c4cc6ba986
--- /dev/null
+++ b/conky/patches/patch-src_entropy.cc
@@ -0,0 +1,15 @@
+$NetBSD$
+
+- Add missing entry for NetBSD.
+
+--- src/entropy.cc.orig 2020-07-27 12:01:52.000000000 +0000
++++ src/entropy.cc
+@@ -40,6 +40,8 @@
+ #include "freebsd.h"
+ #elif defined(__DragonFly__)
+ #include "dragonfly.h"
++#elif defined(__NetBSD__)
++#include "netbsd.h"
+ #elif defined(__OpenBSD__)
+ #include "openbsd.h"
+ #elif defined(__sun)
diff --git a/conky/patches/patch-src_fs.cc b/conky/patches/patch-src_fs.cc
new file mode 100644
index 0000000000..7e2919c3de
--- /dev/null
+++ b/conky/patches/patch-src_fs.cc
@@ -0,0 +1,55 @@
+$NetBSD$
+
+- Fix NetBSD support.
+
+--- src/fs.cc.orig 2020-07-27 12:01:52.000000000 +0000
++++ src/fs.cc
+@@ -42,7 +42,7 @@
+ #include <sys/statfs.h>
+ #endif
+
+-#if defined(__sun)
++#if defined(__sun) || defined(__NetBSD__)
+ #include <sys/statvfs.h>
+ #include <sys/types.h>
+ #endif
+@@ -58,8 +58,8 @@
+ #endif
+
+ #if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && !defined(__OpenBSD__) && \
+- !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__sun) && \
+- !defined(__HAIKU__) && !(defined(__APPLE__) && defined(__MACH__))
++ !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__NetBSD__) && \
++ !defined(__sun) && !defined(__HAIKU__) && !(defined(__APPLE__) && defined(__MACH__))
+ #include <mntent.h>
+ #endif
+
+@@ -126,14 +126,18 @@ struct fs_stat *prepare_fs_stat(const ch
+ #endif /* defined(__APPLE__) */
+
+ static void update_fs_stat(struct fs_stat *fs) {
+-#if defined(__sun)
++#if defined(__sun) || defined(__NetBSD__)
+ struct statvfs s;
+
+ if (statvfs(fs->path, &s) == 0) {
+ fs->size = (long long)s.f_blocks * s.f_frsize;
+ fs->avail = (long long)s.f_bavail * s.f_frsize;
+ fs->free = (long long)s.f_bfree * s.f_frsize;
++#if defined(__NetBSD__)
++ (void)strncpy(fs->type, s.f_fstypename, sizeof(fs->type));
++#else
+ (void)strncpy(fs->type, s.f_basetype, sizeof(fs->type));
++#endif
+ #else
+ struct statfs_struct s {};
+
+@@ -165,7 +169,7 @@ void get_fs_type(const char *path, char
+ NORM_ERR("statfs '%s': %s", path, strerror(errno));
+ }
+ return;
+-#elif defined(__sun)
++#elif defined(__sun) || defined(__NetBSD__)
+ assert(0); /* not used - see update_fs_stat() */
+ #else /* HAVE_STRUCT_STATFS_F_FSTYPENAME */
+
diff --git a/conky/patches/patch-src_netbsd.cc b/conky/patches/patch-src_netbsd.cc
new file mode 100644
index 0000000000..a32458ef4f
--- /dev/null
+++ b/conky/patches/patch-src_netbsd.cc
@@ -0,0 +1,594 @@
+$NetBSD$
+
+- Fix NetBSD support.
+
+--- src/netbsd.cc.orig 2020-07-27 12:01:52.000000000 +0000
++++ src/netbsd.cc
+@@ -30,11 +30,31 @@
+ #include "netbsd.h"
+ #include "net_stat.h"
+
++#include <ifaddrs.h>
++
++#define P_BOOL 0
++#define P_UINT8 1
++#define P_INT64 2
++#define P_STRING 3
++
++#define _DEV_SYSMON "/dev/sysmon"
++
++typedef struct Devquery {
++ int type;
++ const char *dev;
++ const char *key;
++ const char *row;
++} Devquery;
++
++int sysmon_fd;
++
+ static kvm_t *kd = nullptr;
+ int kd_init = 0, nkd_init = 0;
+ u_int32_t sensvalue;
+ char errbuf[_POSIX2_LINE_MAX];
+
++static short conky_cpu_setup = 0;
++
+ static int init_kvm(void) {
+ if (kd_init) { return 0; }
+
+@@ -82,13 +102,13 @@ static int swapmode(int *retavail, int *
+ return 1;
+ }
+
+-void prepare_update() {}
++void prepare_update(void) {}
+
+-void update_uptime() {
++int update_uptime(void) {
+ int mib[2] = {CTL_KERN, KERN_BOOTTIME};
+ struct timeval boottime;
+ time_t now;
+- int size = sizeof(boottime);
++ size_t size = sizeof(boottime);
+
+ if ((sysctl(mib, 2, &boottime, &size, nullptr, 0) != -1) &&
+ (boottime.tv_sec != 0)) {
+@@ -98,136 +118,158 @@ void update_uptime() {
+ warn("could not get uptime");
+ info.uptime = 0;
+ }
++ return 0;
+ }
+
+ int check_mount(struct text_object *obj) {
+- /* stub */
+- (void)obj;
++ int nbmount, i;
++ struct statvfs *mntbuf;
++
++ nbmount = getmntinfo(&mntbuf, MNT_NOWAIT);
++
++ for (i = 0; i < nbmount; i++) {
++ if (strcmp(mntbuf[i].f_mntonname, obj->data.s) == 0) {
++ return 1;
++ }
++ }
+ return 0;
+ }
+
+-void update_meminfo() {
+- int mib[] = {CTL_VM, VM_UVMEXP2};
+- int total_pages, inactive_pages, free_pages;
+- int swap_avail, swap_free;
+- const int pagesize = getpagesize();
++int update_meminfo(void) {
++ int mib[] = { CTL_VM, VM_UVMEXP2 };
+ struct uvmexp_sysctl uvmexp;
+- size_t size = sizeof(uvmexp);
+-
+- if (sysctl(mib, 2, &uvmexp, &size, nullptr, 0) < 0) {
+- warn("could not get memory info");
+- return;
+- }
++ size_t ssize;
+
+- total_pages = uvmexp.npages;
+- free_pages = uvmexp.free;
+- inactive_pages = uvmexp.inactive;
++ ssize = sizeof(uvmexp);
++ memset(&uvmexp, 0, ssize);
+
+- info.memmax = (total_pages * pagesize) >> 10;
+- info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
+- info.memwithbuffers = info.mem;
+- info.memeasyfree = info.memfree = info.memmax - info.mem;
++ info.mem = info.memmax = info.swap = info.swapfree = info.swapmax = 0;
++ info.buffers = info.cached = info.memfree = info.memeasyfree = 0;
++ info.bufmem = 0;
+
+- if (swapmode(&swap_avail, &swap_free) >= 0) {
+- info.swapmax = swap_avail;
+- info.swap = (swap_avail - swap_free);
+- info.swapfree = swap_free;
++ if (sysctl(mib, 2, &uvmexp, &ssize, nullptr, 0) < 0) {
++ warn("could not get memory info");
++ return 0;
+ }
++
++ info.memmax = uvmexp.npages * uvmexp.pagesize / 1024;
++ info.memfree = uvmexp.free * uvmexp.pagesize / 1024;
++ info.memeasyfree = uvmexp.inactive * uvmexp.pagesize / 1024;
++
++ 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.bufmem = info.cached + info.buffers;
++ info.swap = info.swapmax - info.swapfree;
++
++ /*
++ * Counter-adjust for the adjustment in update_stuff in common.c so
++ * that memeasyfree is the inactive memory. Since inactive memory
++ * partially overlaps with buffer memory, but the size of the
++ * overlap is not measured, attempting to split it into non-bufmem
++ * and bufmem parts, as common.c does, can't work. So instead we
++ * report inactive memory as memeasyfree.
++ */
++ info.memeasyfree -= info.bufmem;
++ return 0;
+ }
+
+-void update_net_stats() {
+- int i;
++int
++update_net_stats(void) {
++ struct net_stat *ns;
+ double delta;
+- struct ifnet ifnet;
+- struct ifnet_head ifhead; /* interfaces are in a tail queue */
+- u_long ifnetaddr;
+- static struct nlist namelist[] = {{"_ifnet"}, {nullptr}};
+- static kvm_t *nkd;
+-
+- if (!nkd_init) {
+- nkd = kvm_openfiles(nullptr, NULL, NULL, O_RDONLY, errbuf);
+- if (nkd == nullptr) {
+- 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;
+- }
++ 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 (kvm_read(nkd, (u_long)namelist[0].n_value, (void *)&ifhead,
+- sizeof(ifhead)) < 0) {
+- warn("cannot kvm_read");
+- return;
++ if (getifaddrs(&ifap) < 0) {
++ return 0;
+ }
+
+- /* get delta */
+- delta = current_update_time - last_update_time;
+- if (delta <= 0.0001) { return; }
++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
++ ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
+
+- 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, nullptr, 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);
+- }
++ if (ifa->ifa_flags & IFF_UP) {
++ struct ifaddrs *iftmp;
+
+- ns->last_read_recv = ifnet.if_ibytes;
++ ns->up = 1;
++ last_recv = ns->recv;
++ last_trans = ns->trans;
+
+- if (ifnet.if_obytes < ns->last_read_trans) {
+- ns->trans +=
+- ((long long)4294967295U - ns->last_read_trans) + ifnet.if_obytes;
+- } else {
+- ns->trans += (ifnet.if_obytes - ns->last_read_trans);
+- }
++ if (ifa->ifa_addr->sa_family != AF_LINK) {
++ continue;
++ }
+
+- ns->last_read_trans = ifnet.if_obytes;
++ 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;
+
+- 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;
++ 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;
+
+- ns->recv_speed = (ns->recv - last_recv) / delta;
+- ns->trans_speed = (ns->trans - last_trans) / delta;
++ /* calculate speeds */
++ ns->recv_speed = (ns->recv - last_recv) / delta;
++ ns->trans_speed = (ns->trans - last_trans) / delta;
++ } else {
++ ns->up = 0;
++ }
+ }
+-}
+
+-int update_total_processes() {
+- /* It's easier to use kvm here than sysctl */
++ freeifaddrs(ifap);
+
+- int n_processes;
++ return 0;
++}
+
+- info.procs = 0;
+
+- if (init_kvm() < 0) {
+- return;
+- } else {
+- kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2),
+- &n_processes);
++int update_total_processes(void)
++{
++ int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
++ size_t size;
++
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) < 0) {
++ warn("sysctl KERN_PROC_ALL failed");
++ return 0;
+ }
+
+- info.procs = n_processes;
++ info.procs = (size / sizeof (struct kinfo_proc));
+
+ return 0;
+ }
+
+-void update_running_processes() {
++int update_running_processes(void) {
+ struct kinfo_proc2 *p;
+ int n_processes;
+ int i, cnt = 0;
+@@ -235,7 +277,7 @@ void update_running_processes() {
+ info.run_procs = 0;
+
+ if (init_kvm() < 0) {
+- return;
++ return 0;
+ } else {
+ p = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2),
+ &n_processes);
+@@ -248,50 +290,84 @@ void update_running_processes() {
+ }
+
+ info.run_procs = cnt;
++ return 0;
+ }
+
+-struct cpu_load_struct {
+- unsigned long load[5];
+-};
++void get_cpu_count(void) {
++ int cpu_count = 0;
++ size_t cpu_count_size = sizeof(cpu_count);
++
++ if (sysctlbyname("hw.ncpu", &cpu_count, &cpu_count_size, NULL, 0) != 0 || \
++ cpu_count_size != sizeof(cpu_count)) {
++ fprintf(stderr, "Cannot get hw.ncpu\n");
++ info.cpu_count = 0;
++ } else {
++ info.cpu_count = cpu_count;
++ }
++
++ info.cpu_usage = (float *)malloc((info.cpu_count + 1) * sizeof(float));
++ if (info.cpu_usage == nullptr) { CRIT_ERR(nullptr, NULL, "malloc"); }
++}
+
+-struct cpu_load_struct fresh = {{0, 0, 0, 0, 0}};
++struct cpu_info {
++ long oldtotal;
++ long oldused;
++};
+
+-long cpu_used, oldtotal, oldused;
++int update_cpu_usage(void) {
+
+-void update_cpu_usage() {
++ int i, j = 0;
+ long used, total;
+- static u_int64_t cp_time[CPUSTATES];
+- size_t len = sizeof(cp_time);
++ long *cp_time = nullptr;
++ size_t cp_len;
++ static struct cpu_info *cpu = nullptr;
++ 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 ((conky_cpu_setup == 0) || (!info.cpu_usage)) {
++ get_cpu_count();
++ conky_cpu_setup = 1;
++ }
+
+- info.cpu_usage = 0;
++ if (!global_cpu) {
++ malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
++ cpu = (cpu_info *)malloc(malloc_cpu_size);
++ memset(cpu, 0, malloc_cpu_size);
++ global_cpu = cpu;
++ }
++
++ /* cpu[0] is overall stats, get it from separate sysctl */
++ cp_len = CPUSTATES * sizeof(long);
++ cp_time = (long int *)malloc(cp_len);
+
+- if (sysctlbyname("kern.cp_time", &cp_time, &len, nullptr, 0) < 0) {
+- warn("cannot get kern.cp_time");
++ if (sysctlbyname("kern.cp_time", cp_time, &cp_len, nullptr, 0) < 0) {
++ fprintf(stderr, "Cannot get kern.cp_time\n");
+ }
+
+- 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];
++ total = 0;
++ for (j = 0; j < CPUSTATES; j++) total += cp_time[j];
+
+- used = fresh.load[0] + fresh.load[1] + fresh.load[2];
+- total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
++ used = total - cp_time[CP_IDLE];
+
+- if ((total - oldtotal) != 0) {
+- info.cpu_usage = ((double)(used - oldused)) / (double)(total - oldtotal);
++ 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;
++ info.cpu_usage[0] = 0;
+ }
+
+- oldused = used;
+- oldtotal = total;
++ cpu[0].oldused = used;
++ cpu[0].oldtotal = total;
++
++ free(cp_time);
++ return 0;
+ }
+
+ void free_cpu(struct text_object *) { /* no-op */
+ }
+
+-void update_load_average() {
++int update_load_average(void) {
+ double v[3];
+
+ getloadavg(v, 3);
+@@ -299,32 +375,156 @@ void update_load_average() {
+ info.loadavg[0] = (float)v[0];
+ info.loadavg[1] = (float)v[1];
+ info.loadavg[2] = (float)v[2];
++ return 0;
++}
++
++/* 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 */
++ memset(p_client_buffer, 0, client_buffer_size);
+ }
+
+-double get_acpi_temperature(int fd) { return -1; }
++/* needs root on NetBSD */
++int get_entropy_avail(unsigned int *val) { return 1; }
++
++/* needs root on NetBSD */
++int get_entropy_poolsize(unsigned int *val) { return 1; }
++
++int
++sysmon_open()
++{
++ if (sysmon_fd == -1)
++ sysmon_fd = open(_DEV_SYSMON, O_RDONLY);
++
++ return sysmon_fd == -1;
++}
++
++int8_t
++envsys_get_val(Devquery dq, void *val)
++{
++ const char *descr;
++ const char *cval;
++ prop_dictionary_t dict;
++ prop_object_t device;
++ prop_object_iterator_t iter;
++ prop_object_t obj;
++ prop_string_t str;
++ bool rc = false;
++
++ if (!sysmon_open())
++ 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((prop_array_t)device);
++
++ while((obj = prop_object_iterator_next(iter))) {
++ if (!prop_dictionary_get_cstring_nocopy((prop_dictionary_t)obj, "description", &descr))
++ return -1;
++ if (descr != NULL && *descr) {
++ if(strcmp(descr, dq.key) == 0) {
++ switch(dq.type) {
++ case P_BOOL:
++ rc = prop_dictionary_get_bool((prop_dictionary_t)obj,
++ dq.row, (bool *)val);
++ case P_UINT8:
++ rc = prop_dictionary_get_uint8((prop_dictionary_t)obj,
++ dq.row, (uint8_t *)val);
++ break;
++ case P_INT64:
++ rc = prop_dictionary_get_int64((prop_dictionary_t)obj,
++ dq.row, (int64_t *)val);
++ break;
++ case P_STRING:
++ rc = prop_dictionary_get_cstring_nocopy((prop_dictionary_t)obj,
++ dq.row, &cval);
++ val = (void *)cval;
++ break;
++ }
++ }
++ }
++ }
++
++ prop_object_iterator_release(iter);
++ prop_object_release(dict);
+
+-void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) {}
++ if (rc == false) {
++ val = NULL;
++ return -1;
++ }
++
++ return 0;
++}
+
+ int open_acpi_temperature(const char *name) { return -1; }
+
++double get_acpi_temperature(int fd)
++{
++ Devquery dq_tz = { P_INT64, "acpitz0", "temperature", "cur-value" };
++ int64_t temperature;
++
++ if (envsys_get_val(dq_tz, (void *)&temperature) < 0) {
++ return 0;
++ }
++ return (temperature / 1000000.0) - 273.15;
++}
++
+ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
+ const char *adapter) {
+- (void)adapter; // only linux uses this
++ Devquery dq_acad = { P_BOOL, "acpiacad0", "connected", "cur-value" };
++ bool connected;
+
+ if (!p_client_buffer || client_buffer_size <= 0) { return; }
+
++ if (envsys_get_val(dq_acad, (void *)&connected) < 0) {
++ strncpy(p_client_buffer, "N/A", client_buffer_size);
++ return;
++ }
++
++ if (connected) {
++ strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
++ } else {
++ strncpy(p_client_buffer, "Running on battery", client_buffer_size);
++ }
++}
++
++char get_freq(char *p_client_buffer, size_t client_buffer_size,
++ const char *p_format, int divisor, unsigned int cpu) {
+ /* not implemented */
+- memset(p_client_buffer, 0, client_buffer_size);
++ /* may be possible to implement, but machine dependent */
++ return 0;
+ }
+
+-/* 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; }
++void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) {
++ /* not implemented */
++}
+
++int get_battery_perct(const char *) {
+ /* not implemented */
+- memset(p_client_buffer, 0, client_buffer_size);
++ return 0;
+ }
+
+-int get_entropy_avail(unsigned int *val) { return 1; }
++double get_battery_perct_bar(struct text_object *obj) {
++ /* not implemented */
++ return 0.0;
++}
+
+-int get_entropy_poolsize(unsigned int *val) { return 1; }
++void get_battery_short_status(char *buffer, unsigned int n, const char *bat) {
++ /* not implemented */
++}
++
++int update_diskio(void) {
++ /* not implemented */
++ return 0;
++}
++
++void get_top_info(void) {
++ /* not implemented */
++}
diff --git a/conky/patches/patch-src_netbsd.h b/conky/patches/patch-src_netbsd.h
new file mode 100644
index 0000000000..db6d105658
--- /dev/null
+++ b/conky/patches/patch-src_netbsd.h
@@ -0,0 +1,21 @@
+$NetBSD$
+
+- Fix NetBSD support.
+
+--- src/netbsd.h.orig 2020-07-27 12:01:52.000000000 +0000
++++ src/netbsd.h
+@@ -15,11 +15,13 @@
+ #include <sys/envsys.h>
+ #include <sys/sched.h>
+ #include <sys/socket.h>
++#include <sys/statvfs.h>
+ #include <sys/swap.h>
+ #include <sys/sysctl.h>
+ #include <sys/time.h>
+ #include <sys/types.h>
+-#include <sys/user.h>
++
++#include <prop/proplib.h>
+
+ #include <net/if.h>
+
Home |
Main Index |
Thread Index |
Old Index