@ -11,6 +11,11 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#define SIGRTMIN SIGUSR1 - 1
|
||||
#define SIGRTMAX SIGUSR1 + 1
|
||||
#endif
|
||||
|
||||
namespace waybar {
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
std::vector<float> waybar::modules::CpuFrequency::parseCpuFrequencies() {
|
||||
std::vector<float> frequencies;
|
||||
char buffer[256];
|
||||
size_t len;
|
||||
int32_t freq;
|
||||
uint32_t i = 0;
|
||||
|
||||
#ifndef __OpenBSD__
|
||||
char buffer[256];
|
||||
uint32_t i = 0;
|
||||
while (true) {
|
||||
len = 4;
|
||||
snprintf(buffer, 256, "dev.cpu.%u.freq", i);
|
||||
@ -17,6 +18,12 @@ std::vector<float> waybar::modules::CpuFrequency::parseCpuFrequencies() {
|
||||
frequencies.push_back(freq);
|
||||
++i;
|
||||
}
|
||||
#else
|
||||
int getMhz[] = {CTL_HW, HW_CPUSPEED};
|
||||
len = sizeof(freq);
|
||||
sysctl(getMhz, 2, &freq, &len, NULL, 0);
|
||||
frequencies.push_back((float)freq);
|
||||
#endif
|
||||
|
||||
if (frequencies.empty()) {
|
||||
spdlog::warn("cpu/bsd: parseCpuFrequencies failed, not found in sysctl");
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,13 @@
|
||||
|
||||
#include <poll.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#ifndef __OpenBSD__
|
||||
#include <sys/inotify.h>
|
||||
#else
|
||||
#include <sys/event.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
Reference in New Issue
Block a user