start openbsd ports

This commit is contained in:
bilaliscarioth
2025-07-08 02:13:33 +02:00
parent cae5f9a56f
commit 0cb605b529
5 changed files with 44 additions and 7 deletions

View File

@ -2,7 +2,11 @@
#include <spdlog/spdlog.h>
#include <unistd.h>
#ifndef __OpenBSD__
#include <wordexp.h>
#else
#include <glob.h>
#endif
#include <filesystem>
#include <fstream>
@ -34,6 +38,7 @@ std::vector<std::string> Config::tryExpandPath(const std::string &base,
spdlog::debug("Try expanding: {}", path.string());
std::vector<std::string> results;
#ifndef __OpenBSD__
wordexp_t p;
if (wordexp(path.c_str(), &p, 0) == 0) {
for (size_t i = 0; i < p.we_wordc; i++) {
@ -44,6 +49,18 @@ std::vector<std::string> Config::tryExpandPath(const std::string &base,
}
wordfree(&p);
}
#else
glob_t p;
if (glob(path.c_str(), 0, NULL, &p) == 0) {
for (size_t i = 0; i < p.gl_pathc; i++) {
if (access(p.gl_pathv[i], F_OK) == 0) {
results.emplace_back(p.gl_pathv[i]);
spdlog::debug("Found config file: {}", p.gl_pathv[i]);
}
}
globfree(&p);
}
#endif
return results;
}

View File

@ -10,6 +10,7 @@ std::vector<float> waybar::modules::CpuFrequency::parseCpuFrequencies() {
int32_t freq;
uint32_t i = 0;
#ifndef __OpenBSD__
while (true) {
len = 4;
snprintf(buffer, 256, "dev.cpu.%u.freq", i);
@ -17,6 +18,13 @@ std::vector<float> waybar::modules::CpuFrequency::parseCpuFrequencies() {
frequencies.push_back(freq);
++i;
}
#else
size_t sz;
int psize, cpuspeed, getMhz[] = {CTL_HW, HW_CPUSPEED};
sz = sizeof(cpuspeed);
sysctl(getMhz, 2, &cpuspeed, &sz, NULL, 0);
frequencies.push_back((float)cpuspeed);
#endif
if (frequencies.empty()) {
spdlog::warn("cpu/bsd: parseCpuFrequencies failed, not found in sysctl");

View File

@ -62,7 +62,13 @@ long User::uptime_as_seconds() {
#if HAVE_CPU_BSD
struct timespec s_info;
if (0 == clock_gettime(CLOCK_UPTIME_PRECISE, &s_info)) {
int flags = 0;
#ifndef __OpenBSD__
flags = CLOCK_UPTIME_PRECISE;
#else
flags = CLOCK_UPTIME;
#endif
if (0 == clock_gettime(flags, &s_info)) {
uptime = s_info.tv_sec;
}
#endif

View File

@ -74,9 +74,9 @@ auto Workspaces::handleScroll(GdkEventScroll* e) -> bool {
const auto& wset = ipc->get_wsets().at(output.wset_idx);
auto n = wset.ws_w * wset.ws_h;
auto i = (wset.ws_idx() + delta + n) % n;
data["x"] = i % wset.ws_w;
data["y"] = i / wset.ws_h;
data["output-id"] = output.id;
data["x"] = Json::Value((uint64_t)i % wset.ws_w);
data["y"] = Json::Value((uint64_t)i / wset.ws_h);
data["output-id"] = Json::Value((uint64_t)output.id);
}
ipc->send("vswitch/set-workspace", std::move(data));
@ -108,9 +108,9 @@ auto Workspaces::update_box() -> void {
if (!config_["disable-click"].asBool()) {
btn.signal_pressed().connect([=, this] {
Json::Value data;
data["x"] = i % ws_w;
data["y"] = i / ws_h;
data["output-id"] = output.id;
data["x"] = Json::Value((uint64_t)i % ws_w);
data["y"] = Json::Value((uint64_t)i / ws_h);
data["output-id"] = Json::Value((uint64_t)output.id);
ipc->send("vswitch/set-workspace", std::move(data));
});
}

View File

@ -2,7 +2,13 @@
#include <poll.h>
#include <spdlog/spdlog.h>
#ifndef __OpenBSD__
#include <sys/inotify.h>
#else
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#endif
#include <filesystem>
#include <fstream>