From nobody Sun Aug 06 03:05:51 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RJPTq3P9Cz4mGFY; Sun, 6 Aug 2023 03:05:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RJPTq2xKSz4P7b; Sun, 6 Aug 2023 03:05:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691291151; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tYszWPH9dGTPNeGifQoIsoYuHt4om5qfx0v69Uul8uQ=; b=madcIct1s0QfUkgTABY+2CZh2vWwsP42t/03zOSeo9gQZu857ObDV/Q3P1dzVSqWwN3RjK DQh8ZqZ6QvDO7q9OVon2sY7hsZnF/Rv1DxwIvqGh0hxsspNydyaWzwR5PtTM+bZCVGUU0X njj5aj6GDnsYV+dhXBsfvmLa2LZfpLJBn/KqtrtzRYGsay3vYBCq6HnIMV8fT6fUjIv3PS cSii1pqz1A9SXBWCypqCyYu+NWWzkCI6gPfSELblFRVqOgaKZfLN+tfNCwoCxJC/Z3FzLi JchutfLRrwkfqQVim5k0Nb6Vv8H7zobA78n938m6da9MozN1v7oNiY4L0BNozA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691291151; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tYszWPH9dGTPNeGifQoIsoYuHt4om5qfx0v69Uul8uQ=; b=mrgFgT69i8DGgaFxgMqJmQjLbvVHya1LWF4RfckxaYix2G367F0MKHauTctDxBmCP+K0Hm I3p9M+e/VEjDubUNrjBNKb+2MYjipmiQ7U/itMM7xs431jh5WpYtSdlTkuUZ8fR+AIMFRk S7qgxywKmp/7Umdpo1Vx8UsjXu1ugAHOfdXMtoTzoVuyIKCjEkoQsDvMWTFHSguOM0bxIR 7FP5I69uJ8bdl295s+CVYiCokpM2lrm2HlQf+z5F68NKywANGE6LSOOW0AGQdODmAgibR/ 0Li1FUXj9IWGimnqL+7jlmia11vcySJrKECFOoJHm2jNvsvhc2xwDv12Xo10+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691291151; a=rsa-sha256; cv=none; b=tAb6WyTGF/Vt4It2BNRNu/isjr+o1dlnSD9xNRHp+QTctG06X2IASRZ5ZkiEC/NdfXd39v lpCeZVq/aYO/edt16G1TKj1oQVnKFYRqPmlnk9DSFPYqTe6/U+z82jfHPRIYJ6Qd/gxpRs GzqHq38Hkz/haeTQ2Yu9WEx9rqKTA+7RD+0mN2WhNMuGhI5v/1pbcv2mZqmmzN/O8KOknB iSwfrzUQ7/uoRY4ecFoW/DRlSI+L0lW34MecFJUjqqd6dxWniFa1JOS9TtpaGWthvSBuLF mU58sBqUr6cOROSRzfa3ki2KAolymrcyhIDRJQQfyFattdTuHOFlRTi4lYmhgg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RJPTq20pczvB7; Sun, 6 Aug 2023 03:05:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37635pSj093395; Sun, 6 Aug 2023 03:05:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37635p40093394; Sun, 6 Aug 2023 03:05:51 GMT (envelope-from git) Date: Sun, 6 Aug 2023 03:05:51 GMT Message-Id: <202308060305.37635p40093394@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: "=?utf-8?Q?Alexandre=20C.=20Guimar=C3=A3es?=" Subject: git: 6cdddcb8fd5d - main - x11/polybar: Add patches for CPU and memory modules List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rigoletto X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6cdddcb8fd5df5db70abb86c4abe56664b60c7f9 Auto-Submitted: auto-generated The branch main has been updated by rigoletto: URL: https://cgit.FreeBSD.org/ports/commit/?id=6cdddcb8fd5df5db70abb86c4abe56664b60c7f9 commit 6cdddcb8fd5df5db70abb86c4abe56664b60c7f9 Author: Joel Bodenmann AuthorDate: 2023-08-06 03:04:55 +0000 Commit: Alexandre C. GuimarĂ£es CommitDate: 2023-08-06 03:04:55 +0000 x11/polybar: Add patches for CPU and memory modules - give it to Joel Bodenmann PR: 272831 --- x11/polybar/Makefile | 4 +- x11/polybar/files/patch-src_modules_cpu.cpp | 66 ++++++++++++++++++++++++++ x11/polybar/files/patch-src_modules_memory.cpp | 49 +++++++++++++++++++ x11/polybar/pkg-message | 4 +- 4 files changed, 119 insertions(+), 4 deletions(-) diff --git a/x11/polybar/Makefile b/x11/polybar/Makefile index c0de6b457108..a3272a58bb56 100644 --- a/x11/polybar/Makefile +++ b/x11/polybar/Makefile @@ -1,10 +1,10 @@ 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 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 @@ -6,10 +6,12 @@ not function in FreeBSD. Working modules: - bspwm +- cpu - date - github - i3 - ipc (polybar-msg method does not seem to work) +- memory - menu - mpd - script @@ -19,9 +21,7 @@ Working modules: - xworkspaces (not extensively tested) Broken modules: -- cpu - filesystem -- memory - network (requires wireless_tools) - temperature (requires /sys/class/thermal/* in sysfs) - volume (requires full alsa, not a wrapper)