diff --git a/x11/polybar/Makefile b/x11/polybar/Makefile index c0de6b457108..a3272a58bb56 100644 --- a/x11/polybar/Makefile +++ b/x11/polybar/Makefile @@ -1,96 +1,96 @@ PORTNAME= polybar DISTVERSION= 3.6.3 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= x11 MASTER_SITES= https://github.com/polybar/polybar/releases/download/${DISTVERSION}/ -MAINTAINER= rigoletto@FreeBSD.org +MAINTAINER= jbo@insane.engineer COMMENT= Fast and easy-to-use status bar WWW= https://github.com/polybar/polybar LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE BUILD_DEPENDS= xcb-proto>=1.9:x11/xcb-proto LIB_DEPENDS= libfontconfig.so:x11-fonts/fontconfig \ libfreetype.so:print/freetype2 \ libinotify.so:devel/libinotify \ libuv.so:devel/libuv \ libxcb-ewmh.so:x11/xcb-util-wm \ libxcb-icccm.so:x11/xcb-util-wm \ libxcb-image.so:x11/xcb-util-image \ libxcb-util.so:x11/xcb-util \ libxcb-xrm.so:x11/xcb-util-xrm # compiler:c++11-lang is needed for powerpc64 USES= cmake compiler:c++11-lang gnome localbase:ldflags \ pkgconfig python:build xorg USE_GNOME= cairo USE_XORG= xcb # Needs libnl to work. Disabling it completely. CMAKE_OFF= ENABLE_NETWORK BUILD_DOC OPTIONS_DEFINE= ALSA CURSOR DEBUG GITHUB I3 IPC MPD \ PULSEAUDIO TESTS XKEYBOARD OPTIONS_DEFAULT= CURSOR GITHUB I3 IPC MPD PULSEAUDIO XKEYBOARD OPTIONS_SUB= yes ALSA_DESC= Shows volume and mute state for Alsa CURSOR_DESC= Required for click and scroll settings GITHUB_DESC= Shows the unread notification count I3_DESC= Uses the i3 IPC to display information IPC_DESC= Built-in IPC support MPD_DESC= Support for controlling MPD TESTS_DESC= Build testsuite XKEYBOARD_DESC= Shows the current layout and active indicators ALSA_CMAKE_BOOL= ENABLE_ALSA ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib CURSOR_CMAKE_BOOL= WITH_XCURSOR CURSOR_LIB_DEPENDS= libxcb-cursor.so:x11/xcb-util-cursor DEBUG_CMAKE_BOOL= DEBUG_LOGGER GITHUB_CMAKE_BOOL= ENABLE_CURL GITHUB_LIB_DEPENDS= libcurl.so:ftp/curl I3_BUILD_DEPENDS= ${LOCALBASE}/include/i3/ipc.h:x11-wm/i3 I3_CMAKE_BOOL= ENABLE_I3 I3_LIB_DEPENDS= libjsoncpp.so:devel/jsoncpp IPC_CMAKE_BOOL= BUILD_IPC_MSG MPD_CMAKE_BOOL= ENABLE_MPD MPD_LIB_DEPENDS= libmpdclient.so:audio/libmpdclient PULSEAUDIO_CMAKE_BOOL= ENABLE_PULSEAUDIO PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio # fail while building on poudriere because it needs network access # during the building process to download googletest on-the-fly. TESTS_BUILD_DEPENDS= git>=0:devel/git TESTS_CMAKE_BOOL= BUILD_TESTS XKEYBOARD_CMAKE_BOOL= ENABLE_XKEYBOARD XKEYBOARD_LIB_DEPENDS= libxcb-xkb.so:x11/libxcb ETCFIX = include/utils/command.hpp \ contrib/bash/polybar \ contrib/zsh/_polybar \ doc/man/polybar.1.rst \ doc/man/polybar.5.rst \ CHANGELOG.md post-patch: .for f in ${ETCFIX} @${REINPLACE_CMD} -e 's|/etc|${PREFIX}/etc|g' ${WRKSRC}/${f} .endfor do-test-TESTS-on: cd ${TEST_WRKSRC} && ${SETENV} BUILD_TESTS=ON \ ${SH} ${WRKSRC}/common/travis/tests.sh .include diff --git a/x11/polybar/files/patch-src_modules_cpu.cpp b/x11/polybar/files/patch-src_modules_cpu.cpp new file mode 100644 index 000000000000..7d31e2c08bff --- /dev/null +++ b/x11/polybar/files/patch-src_modules_cpu.cpp @@ -0,0 +1,66 @@ +diff --git src/modules/cpu.cpp src/modules/cpu.cpp +index 527f27fb..179d9221 100644 +--- src/modules/cpu.cpp ++++ src/modules/cpu.cpp +@@ -2,6 +2,11 @@ + + #include + #include ++#ifdef __FreeBSD__ ++ #include ++ #include ++ #include ++#endif + + #include "drawtypes/label.hpp" + #include "drawtypes/progressbar.hpp" +@@ -128,6 +133,41 @@ namespace modules { + m_cputimes.clear(); + + try { ++#ifdef __FreeBSD__ ++ // Get number of CPUs ++ // ToDo: No need to do this on every invocation. ++ int ncpu = -1; ++ std::size_t sz = sizeof(ncpu); ++ if (sysctlbyname("hw.ncpu", &ncpu, &sz, nullptr, 0) != 0) { ++ m_log.err("Failed to query sysctl 'hw.ncpu' (errno: %s)", strerror(errno)); ++ return false; ++ } ++ if (ncpu < 1) { ++ m_log.err("Failed to determine number of CPUs."); ++ return false; ++ } ++ ++ // Query 'kern.cp_time' ++ long cpu_stat[CPUSTATES]; ++ sz = sizeof(cpu_stat); ++ if (sysctlbyname("kern.cp_time", cpu_stat, &sz, nullptr, 0) != 0) { ++ m_log.err("Failed to query sysctl 'kern.cp_time' (errno: %s)", strerror(errno)); ++ return false; ++ } ++ ++ // Parse ++ static std::size_t field_offset = sizeof(*cpu_stat) + ncpu; ++ for (std::size_t i = 0; i < ncpu; i++) { ++ m_cputimes.emplace_back(new cpu_time); ++ m_cputimes.back()->user = cpu_stat[CP_USER]; ++ m_cputimes.back()->nice = cpu_stat[CP_NICE]; ++ m_cputimes.back()->system = cpu_stat[CP_SYS]; ++ m_cputimes.back()->steal = cpu_stat[CP_INTR]; // Note: This is technically the reported "interrupt" time ++ m_cputimes.back()->idle = cpu_stat[CP_IDLE]; ++ m_cputimes.back()->total = m_cputimes.back()->user + m_cputimes.back()->nice + m_cputimes.back()->system + ++ m_cputimes.back()->idle + m_cputimes.back()->steal; ++ } ++#else + std::ifstream in(PATH_CPU_INFO); + string str; + +@@ -148,6 +188,7 @@ namespace modules { + m_cputimes.back()->total = m_cputimes.back()->user + m_cputimes.back()->nice + m_cputimes.back()->system + + m_cputimes.back()->idle + m_cputimes.back()->steal; + } ++#endif + } catch (const std::ios_base::failure& e) { + m_log.err("Failed to read CPU values (what: %s)", e.what()); + } diff --git a/x11/polybar/files/patch-src_modules_memory.cpp b/x11/polybar/files/patch-src_modules_memory.cpp new file mode 100644 index 000000000000..b0d836e120db --- /dev/null +++ b/x11/polybar/files/patch-src_modules_memory.cpp @@ -0,0 +1,49 @@ +diff --git src/modules/memory.cpp src/modules/memory.cpp +index eb36e5dc..042d85cb 100644 +--- src/modules/memory.cpp ++++ src/modules/memory.cpp +@@ -1,6 +1,10 @@ + #include + #include + #include ++#ifdef __FreeBSD__ ++ #include ++ #include ++#endif + + #include "drawtypes/label.hpp" + #include "drawtypes/progressbar.hpp" +@@ -63,6 +67,25 @@ namespace modules { + unsigned long long kb_swap_free{0ULL}; + + try { ++#ifdef __FreeBSD__ ++ std::size_t sz; ++ ++ // Total ++ sz = sizeof(kb_total); ++ if (sysctlbyname("hw.physmem", &kb_total, &sz, nullptr, 0) != 0) { ++ m_log.err("Failed to query sysctl 'hw.physmem' (errno: %s)", strerror(errno)); ++ return false; ++ } ++ kb_total /= 1024; ++ ++ // Available ++ sz = sizeof(kb_avail); ++ if (sysctlbyname("hw.usermem", &kb_avail, &sz, nullptr, 0) != 0) { ++ m_log.err("Failed to query sysctl 'hw.usermem' (errno: %s)", strerror(errno)); ++ return false; ++ } ++ kb_avail /= 1024; ++#else + std::ifstream meminfo(PATH_MEMORY_INFO); + std::map parsed; + +@@ -91,6 +114,7 @@ namespace modules { + // old kernel; give a best-effort approximation of available memory + kb_avail = parsed["MemFree"] + parsed["Buffers"] + parsed["Cached"] + parsed["SReclaimable"] - parsed["Shmem"]; + } ++#endif + } catch (const std::exception& err) { + m_log.err("Failed to read memory values (what: %s)", err.what()); + } diff --git a/x11/polybar/pkg-message b/x11/polybar/pkg-message index ed6bc5b10f26..30a0aa183ced 100644 --- a/x11/polybar/pkg-message +++ b/x11/polybar/pkg-message @@ -1,35 +1,35 @@ [ { type: install message: <