pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Import waybar
Module Name: pkgsrc-wip
Committed By: kikadf <kikadf.01%gmail.com@localhost>
Pushed By: kikadf
Date: Sat Dec 20 20:33:45 2025 +0100
Changeset: 741fd60bab904c07f8608bbeed67cce3f309132d
Modified Files:
Makefile
Added Files:
waybar/DESCR
waybar/Makefile
waybar/PLIST
waybar/TODO
waybar/distinfo
waybar/patches/patch-meson.build
waybar/patches/patch-src_modules_battery.cpp
waybar/patches/patch-src_modules_custom.cpp
waybar/patches/patch-src_modules_simpleclock.cpp
waybar/patches/patch-src_modules_user.cpp
Log Message:
Import waybar
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=741fd60bab904c07f8608bbeed67cce3f309132d
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 +
waybar/DESCR | 2 +
waybar/Makefile | 56 ++++++
waybar/PLIST | 42 +++++
waybar/TODO | 8 +
waybar/distinfo | 10 ++
waybar/patches/patch-meson.build | 49 ++++++
waybar/patches/patch-src_modules_battery.cpp | 208 +++++++++++++++++++++++
waybar/patches/patch-src_modules_custom.cpp | 16 ++
waybar/patches/patch-src_modules_simpleclock.cpp | 17 ++
waybar/patches/patch-src_modules_user.cpp | 21 +++
11 files changed, 430 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index 6f265be147..1f1dc2a5e3 100644
--- a/Makefile
+++ b/Makefile
@@ -6039,6 +6039,7 @@ SUBDIR+= wasi-libc-git
SUBDIR+= wasi-libcxx
SUBDIR+= watch
SUBDIR+= watchman
+SUBDIR+= waybar
SUBDIR+= wcstools
SUBDIR+= weatherman
SUBDIR+= web-mode
diff --git a/waybar/DESCR b/waybar/DESCR
new file mode 100644
index 0000000000..961e5027c7
--- /dev/null
+++ b/waybar/DESCR
@@ -0,0 +1,2 @@
+Highly customizable Wayland bar for Sway and
+Wlroots based compositors.
diff --git a/waybar/Makefile b/waybar/Makefile
new file mode 100644
index 0000000000..0b312e94fa
--- /dev/null
+++ b/waybar/Makefile
@@ -0,0 +1,56 @@
+# $NetBSD$
+
+DISTNAME= waybar-0.14.0
+CATEGORIES= x11
+MASTER_SITES= ${MASTER_SITE_GITHUB:=Alexays/}
+GITHUB_PROJECT= Waybar
+GITHUB_TAG= ${PKGVERSION_NOREV}
+
+MAINTAINER= kikadf.01%gmail.com@localhost
+HOMEPAGE= https://github.com/Alexays/Waybar/
+COMMENT= Wayland bar for Wlroots based compositors
+LICENSE= mit
+
+USE_CXX_FEATURES+= filesystem
+USE_LANGUAGES= c c++
+
+USE_TOOLS+= pkg-config gdbus-codegen
+#TOOL_DEPENDS+= scdoc-[0-9]*:../../textproc/scdoc
+
+SUBST_CLASSES+= nogit
+SUBST_STAGE.nogit= pre-configure
+SUBST_MESSAGE.nogit= Set version
+SUBST_FILES.nogit+= meson.build
+SUBST_SED.nogit+= -e 's/git =/\#git =/g'
+SUBST_SED.nogit+= -e 's/git.found()/false/g'
+SUBST_SED.nogit+= -e '/project_version/s/@0@/${PKGVERSION}/g'
+
+EGDIR= ${PREFIX}/share/examples/labwc
+CONF_FILES= ${EGDIR}/config.json ${PKG_SYSCONFDIR}/config.json
+CONF_FILES+= ${EGDIR}/style.css ${PKG_SYSCONFDIR}/style.css
+
+PKG_SYSCONFSUBDIR= xdg/waybar
+
+#INSTALLATION_DIRS+= ${PKGMANDIR}/man1
+
+#post-install:
+# scdoc < ${WRKSRC}/swaybg.1.scd > ${WRKSRC}/swaybg.1
+# ${INSTALL_MAN} ${WRKSRC}/swaybg.1 \
+# ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/swaybg.1
+
+.include "../../wip/gtk-layer-shell/buildlink3.mk"
+
+.include "../../devel/meson/build.mk"
+.include "../../textproc/scdoc/tool.mk"
+.include "../../devel/libdbusmenu-gtk3/buildlink3.mk"
+.include "../../devel/libinotify/buildlink3.mk"
+.include "../../devel/spdlog/buildlink3.mk"
+.include "../../devel/wayland/buildlink3.mk"
+.include "../../devel/wayland-protocols/buildlink3.mk"
+.include "../../geography/gpsd/buildlink3.mk"
+.include "../../textproc/fmtlib/buildlink3.mk"
+.include "../../textproc/jsoncpp/buildlink3.mk"
+.include "../../textproc/libxml2/buildlink3.mk"
+.include "../../x11/libxkbcommon/buildlink3.mk"
+.include "../../x11/gtkmm3/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/waybar/PLIST b/waybar/PLIST
new file mode 100644
index 0000000000..1a46c04e71
--- /dev/null
+++ b/waybar/PLIST
@@ -0,0 +1,42 @@
+@comment $NetBSD$
+bin/waybar
+examples/waybar/config.jsonc
+examples/waybar/style.css
+man/man5/waybar-battery.5
+man/man5/waybar-cffi.5
+man/man5/waybar-clock.5
+man/man5/waybar-cpu.5
+man/man5/waybar-custom.5
+man/man5/waybar-disk.5
+man/man5/waybar-dwl-tags.5
+man/man5/waybar-dwl-window.5
+man/man5/waybar-ext-workspaces.5
+man/man5/waybar-gamemode.5
+man/man5/waybar-gps.5
+man/man5/waybar-hyprland-language.5
+man/man5/waybar-hyprland-submap.5
+man/man5/waybar-hyprland-window.5
+man/man5/waybar-hyprland-workspaces.5
+man/man5/waybar-idle-inhibitor.5
+man/man5/waybar-image.5
+man/man5/waybar-inhibitor.5
+man/man5/waybar-memory.5
+man/man5/waybar-menu.5
+man/man5/waybar-niri-language.5
+man/man5/waybar-niri-window.5
+man/man5/waybar-niri-workspaces.5
+man/man5/waybar-river-layout.5
+man/man5/waybar-river-mode.5
+man/man5/waybar-river-tags.5
+man/man5/waybar-river-window.5
+man/man5/waybar-states.5
+man/man5/waybar-styles.5
+man/man5/waybar-sway-language.5
+man/man5/waybar-sway-mode.5
+man/man5/waybar-sway-scratchpad.5
+man/man5/waybar-sway-window.5
+man/man5/waybar-sway-workspaces.5
+man/man5/waybar-temperature.5
+man/man5/waybar-tray.5
+man/man5/waybar-wlr-taskbar.5
+man/man5/waybar.5
diff --git a/waybar/TODO b/waybar/TODO
new file mode 100644
index 0000000000..93f4759d15
--- /dev/null
+++ b/waybar/TODO
@@ -0,0 +1,8 @@
+options:
+-audio visualizer: cava (need to port)
+-keyboard state: evdev, libinput (test: libevdev-chunk, libopeninput)
+-mpris media player remote interface: playerctl (need to port)
+-backlight:
+-volume: pulse, jack, sndio (no audioio..)
+
+Not tested yet
diff --git a/waybar/distinfo b/waybar/distinfo
new file mode 100644
index 0000000000..74c22d2cbb
--- /dev/null
+++ b/waybar/distinfo
@@ -0,0 +1,10 @@
+$NetBSD$
+
+BLAKE2s (waybar-0.14.0.tar.gz) = 11cff6a2a8923fdc41d055203c00e115c555e9ad45ac613c56ebcfa8c9bd8ad1
+SHA512 (waybar-0.14.0.tar.gz) = dc3d18f7117be8cce5979029110770699b0d9d737337c3cf27361d6ceda6fcde33dac9781e406a70eb24c9e0e95e3801d47e81d44bfb61c311510fb30dd975a7
+Size (waybar-0.14.0.tar.gz) = 341661 bytes
+SHA1 (patch-meson.build) = 0963fed3f36e52ceb2028c4a87714bbc0add6f90
+SHA1 (patch-src_modules_battery.cpp) = a50d16904dd9f9d229cb806f28416005eadae835
+SHA1 (patch-src_modules_custom.cpp) = 644740e4862444b7ed33523affe5d97e5fcbdd32
+SHA1 (patch-src_modules_simpleclock.cpp) = 7ffa485e5cc9033e090d46133654243cbd1b3f8d
+SHA1 (patch-src_modules_user.cpp) = 7b9d5578a64d2b1fefbecd650549c5e9f8ea19ad
diff --git a/waybar/patches/patch-meson.build b/waybar/patches/patch-meson.build
new file mode 100644
index 0000000000..1fa58f7f22
--- /dev/null
+++ b/waybar/patches/patch-meson.build
@@ -0,0 +1,49 @@
+$NetBSD$
+
+* Build battery on NetBSD, link with -lprop
+* Config files to examples
+
+--- meson.build.orig 2025-08-08 07:15:22.000000000 +0000
++++ meson.build
+@@ -58,15 +58,19 @@ if compiler.links(code, name : 'nl_langi
+ add_project_arguments('-DHAVE_LANGINFO_1STDAY', language: 'cpp')
+ endif
+
+-add_global_arguments(cpp_args, language : 'cpp')
+-add_global_link_arguments(cpp_link_args, language : 'cpp')
+-
+ is_linux = host_machine.system() == 'linux'
+ is_dragonfly = host_machine.system() == 'dragonfly'
+ is_freebsd = host_machine.system() == 'freebsd'
+ is_netbsd = host_machine.system() == 'netbsd'
+ is_openbsd = host_machine.system() == 'openbsd'
+
++if is_netbsd
++ cpp_link_args += ['-lprop']
++endif
++
++add_global_arguments(cpp_args, language : 'cpp')
++add_global_link_arguments(cpp_link_args, language : 'cpp')
++
+ thread_dep = dependency('threads')
+ fmt = dependency('fmt', version : ['>=8.1.1'], fallback : ['fmt', 'fmt_dep'])
+ spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled', 'std_format=disabled', 'tests=disabled'])
+@@ -245,7 +249,7 @@ elif is_dragonfly or is_freebsd or is_ne
+ 'man/waybar-cpu.5.scd',
+ 'man/waybar-memory.5.scd',
+ )
+- if is_freebsd
++ if is_freebsd or is_netbsd
+ src_files += files('src/modules/battery.cpp')
+ man_files += files('man/waybar-battery.5.scd')
+ endif
+@@ -563,7 +567,8 @@ executable(
+ install_data(
+ 'resources/config.jsonc',
+ 'resources/style.css',
+- install_dir: sysconfdir / 'xdg/waybar'
++ #install_dir: sysconfdir / 'xdg/waybar'
++ install_dir: prefix / 'examples/waybar'
+ )
+
+ scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
diff --git a/waybar/patches/patch-src_modules_battery.cpp b/waybar/patches/patch-src_modules_battery.cpp
new file mode 100644
index 0000000000..29dd3a92d2
--- /dev/null
+++ b/waybar/patches/patch-src_modules_battery.cpp
@@ -0,0 +1,208 @@
+$NetBSD$
+
+* Add NetBSD support
+
+--- src/modules/battery.cpp.orig 2025-08-08 07:15:22.000000000 +0000
++++ src/modules/battery.cpp
+@@ -2,6 +2,7 @@
+
+ #include <algorithm>
+ #include <cctype>
++#include <cstddef>
+
+ #include "util/command.hpp"
+ #if defined(__FreeBSD__)
+@@ -9,6 +10,67 @@
+ #endif
+ #include <spdlog/spdlog.h>
+
++#if defined(__NetBSD__)
++#include <fcntl.h>
++#include <unistd.h>
++#include <prop/proplib.h>
++#include <sys/envsys.h>
++
++#define SYSMON "/dev/sysmon"
++
++static prop_array_t get_device(const char* name) {
++ prop_dictionary_t dict;
++ prop_object_t obj;
++ prop_array_t array;
++ int fd;
++
++ if (name == nullptr) { return nullptr; }
++ if ((fd = open(SYSMON, O_RDONLY)) < 0) { return nullptr; }
++ if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &dict) != 0) {
++ close(fd);
++ return nullptr;
++ }
++ close(fd);
++
++ if ((obj = prop_dictionary_get(dict, name)) == nullptr) {
++ prop_object_release(dict);
++ return nullptr;
++ }
++ if (prop_object_type(obj) != PROP_TYPE_ARRAY) {
++ prop_object_release(dict);
++ return nullptr;
++ }
++
++ array = (prop_array_t)obj;
++ prop_object_retain(array);
++ prop_object_release(dict);
++
++ return array;
++}
++
++static int64_t handle_stat(prop_dictionary_t stat, const char * key) {
++ prop_object_t obj;
++
++ if ((stat == nullptr || key == nullptr) ||
++ ((obj = prop_dictionary_get(stat, key)) == nullptr) ||
++ (prop_object_type(obj) != PROP_TYPE_NUMBER))
++ { return -1; }
++
++ return prop_number_signed_value((prop_number_t)obj);
++}
++
++static bool stat_is_valid(prop_dictionary_t stat) {
++ prop_object_t oBbj;
++
++ if ((stat == nullptr) ||
++ ((obj = prop_dictionary_get(stat, "state")) == nullptr) ||
++ (prop_object_type(obj) != PROP_TYPE_STRING))
++ { return false; }
++
++ return prop_string_equals_string((prop_string_t)obj, "valid");
++}
++#endif
++
+ waybar::modules::Battery::Battery(const std::string& id, const Bar& bar, const Json::Value& config)
+ : ALabel(config, "battery", id, "{capacity}%", 60), last_event_(""), bar_(bar) {
+ #if defined(__linux__)
+@@ -54,7 +116,7 @@ waybar::modules::Battery::~Battery() {
+ }
+
+ void waybar::modules::Battery::worker() {
+-#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ thread_timer_ = [this] {
+ dp.emit();
+ thread_timer_.sleep_for(interval_);
+@@ -240,6 +302,77 @@ waybar::modules::Battery::getInfos() {
+ // spdlog::info("{} {} {} {}", capacity,time,status,rate);
+ return {capacity, time / 60.0, status, rate, 0, 0.0F};
+
++#elif defined(__NetBSD__)
++ //Need: [capacity, time_remaining, status, power, cycles, health]
++ // [uint8_t, float, std::string, float, uint16_t, float ]
++ prop_array_t bat;
++ prop_object_iterator_t iter;
++ prop_dictionary_t id;
++ prop_string_t desc;
++ uint8_t cur_charge = 0;
++ uint8_t max_charge = 0;
++ uint8_t charge_rate = 0;
++ std::string status;
++ uint8_t capacity;
++ float time_remaining;
++ float power;
++ bool is_present = false;
++
++ if ((bat = get_device("acpibat0")) == nullptr) {
++ throw std::runtime_error("get acpibat0 device info failed");
++ }
++ if ((iter = prop_array_iterator(bat)) == nullptr) {
++ prop_object_release(bat);
++ throw std::runtime_error("prop_array_iterator failed");
++ }
++ while ((id = (prop_dictionary_t)prop_object_iterator_next(iter)) != nullptr) {
++ desc = (prop_string_t)prop_dictionary_get(id, "description");
++ if (desc == nullptr) continue;
++ if (prop_string_equals_string(desc, "charge")) {
++ cur_charge = handle_stat(id, "cur-value");
++ max_charge = handle_stat(id, "max-value");
++ } else if (prop_string_equals_string(desc, "charge rate")) {
++ if (stat_is_valid(id)) charge_rate = handle_stat(id, "cur-value");
++ } else if (prop_string_equals_string(desc, "discharge rate")) {
++ if (stat_is_valid(id)) charge_rate = handle_stat(id, "cur-value");
++ } else if (prop_string_equals_string(desc, "present")) {
++ is_present = (handle_stat(id, "cur-value") == 1);
++ }
++ }
++ prop_object_iterator_release(iter);
++ prop_object_release(bat);
++
++ if (charge_rate == 0) {
++ time_remaining = 0.0;
++ power = 0.0;
++ } else {
++ time_remaining = ((max_charge - cur_charge) * 60) / charge_rate;
++ power = charge_rate;
++ }
++
++ capacity = (cur_charge * 100) / max_charge;
++ // Handle full-at
++ if (config_["full-at"].isUInt()) {
++ auto full_at = config_["full-at"].asUInt();
++ if (full_at < 100) {
++ capacity = 100.f * capacity / full_at;
++ }
++ }
++ if (capacity > 100.f) {
++ // This can happen when the battery is calibrating and goes above 100%
++ // Handle it gracefully by clamping at 100%
++ capacity = 100.f;
++ }
++ if (!is_present) {
++ time_remaining = 0.0;
++ power = 0.0;
++ capacity = 0;
++ }
++ status = getAdapterStatus(capacity);
++
++ // spdlog::info("{} {} {} {}", capacity,time_remaining,status,power);
++ return {capacity, time_remaining, status, power, 0, 0.0F};
++
+ #elif defined(__linux__)
+ uint32_t total_power = 0; // μW
+ bool total_power_exists = false;
+@@ -632,6 +765,38 @@ const std::string waybar::modules::Batte
+ bool online = state == 2;
+ std::string status{"Unknown"}; // TODO: add status in FreeBSD
+ {
++#elif defined(__NetBSD__)
++ prop_array_t ac;
++ prop_object_iterator_t iter;
++ prop_dictionary_t id;
++ prop_string_t desc;
++ std::string status;
++ bool online = false;
++
++ if ((ac = get_device("acpiacad0")) == nullptr) {
++ status = "Unknown";
++ } else {
++ if ((iter = prop_array_iterator(ac)) == nullptr){
++ prop_object_release(ac);
++ throw std::runtime_error("prop_array_iterator failed");
++ }
++ while ((id = (prop_dictionary_t)prop_object_iterator_next(iter)) != nullptr) {
++ desc = (prop_string_t)prop_dictionary_get(id, "description");
++ if (desc == nullptr) continue;
++ if (!prop_string_equals_string(desc, "connected")) continue;
++ // Unknown > Full > Not charging > Discharging > Charging
++ if (handle_stat(id, "cur-value") != 0) {
++ status = "Charging";
++ online = true;
++ } else {
++ status = "Discharging";
++ }
++ break;
++ }
++ prop_object_iterator_release(iter);
++ prop_object_release(ac);
++ }
++ {
+ #else
+ if (!adapter_.empty()) {
+ bool online;
diff --git a/waybar/patches/patch-src_modules_custom.cpp b/waybar/patches/patch-src_modules_custom.cpp
new file mode 100644
index 0000000000..4210c7c764
--- /dev/null
+++ b/waybar/patches/patch-src_modules_custom.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+* Portable WEXITSTATUS usage
+
+--- src/modules/custom.cpp.orig 2025-12-18 09:25:10.973327997 +0000
++++ src/modules/custom.cpp
+@@ -81,7 +81,8 @@ void waybar::modules::Custom::continuous
+ if (getline(&buff, &len, fp_) == -1) {
+ int exit_code = 1;
+ if (fp_) {
+- exit_code = WEXITSTATUS(util::command::close(fp_, pid_));
++ int status = util::command::close(fp_, pid_);
++ exit_code = WEXITSTATUS(status);
+ fp_ = nullptr;
+ }
+ if (exit_code != 0) {
diff --git a/waybar/patches/patch-src_modules_simpleclock.cpp b/waybar/patches/patch-src_modules_simpleclock.cpp
new file mode 100644
index 0000000000..f3f46b37b5
--- /dev/null
+++ b/waybar/patches/patch-src_modules_simpleclock.cpp
@@ -0,0 +1,17 @@
+$NetBSD$
+
+* fmt::localtime was removed in fmtlib-12
+
+--- src/modules/simpleclock.cpp.orig 2025-12-18 09:42:22.535423519 +0000
++++ src/modules/simpleclock.cpp
+@@ -17,7 +17,9 @@ waybar::modules::Clock::Clock(const std:
+ auto waybar::modules::Clock::update() -> void {
+ tzset(); // Update timezone information
+ auto now = std::chrono::system_clock::now();
+- auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now));
++ auto t = std::chrono::system_clock::to_time_t(now);
++ std::tm localtime{};
++ localtime_r(&t, &localtime);
+ auto text = fmt::format(fmt::runtime(format_), localtime);
+ label_.set_markup(text);
+
diff --git a/waybar/patches/patch-src_modules_user.cpp b/waybar/patches/patch-src_modules_user.cpp
new file mode 100644
index 0000000000..829bd855c9
--- /dev/null
+++ b/waybar/patches/patch-src_modules_user.cpp
@@ -0,0 +1,21 @@
+$NetBSD$
+
+* Portable uptime usage, fallback to CLOCK_MONOTONIC
+
+--- src/modules/user.cpp.orig 2025-12-18 09:12:40.964198952 +0000
++++ src/modules/user.cpp
+@@ -63,10 +63,12 @@ long User::uptime_as_seconds() {
+ #if HAVE_CPU_BSD
+ struct timespec s_info;
+ int flags = 0;
+-#ifndef __OpenBSD__
++#ifdef CLOCK_UPTIME_PRECISE
+ flags = CLOCK_UPTIME_PRECISE;
+-#else
++#elif defined(CLOCK_UPTIME)
+ flags = CLOCK_UPTIME;
++#else
++ flags = CLOCK_MONOTONIC;
+ #endif
+ if (0 == clock_gettime(flags, &s_info)) {
+ uptime = s_info.tv_sec;
Home |
Main Index |
Thread Index |
Old Index