fix: lint

This commit is contained in:
Alex
2026-02-24 00:49:23 +01:00
parent ef3d55980e
commit 802bf184fb
8 changed files with 39 additions and 16 deletions

View File

@ -158,7 +158,8 @@ void AAppIconLabel::updateAppIcon() {
} else if (app_icon_name_.front() == '/') { } else if (app_icon_name_.front() == '/') {
try { try {
int scaled_icon_size = app_icon_size_ * image_.get_scale_factor(); int scaled_icon_size = app_icon_size_ * image_.get_scale_factor();
auto pixbuf = Gdk::Pixbuf::create_from_file(app_icon_name_, scaled_icon_size, scaled_icon_size); auto pixbuf =
Gdk::Pixbuf::create_from_file(app_icon_name_, scaled_icon_size, scaled_icon_size);
auto surface = Gdk::Cairo::create_surface_from_pixbuf(pixbuf, image_.get_scale_factor(), auto surface = Gdk::Cairo::create_surface_from_pixbuf(pixbuf, image_.get_scale_factor(),
image_.get_window()); image_.get_window());

View File

@ -142,7 +142,7 @@ static void handleSignalMainThread(int signum, bool& reload) {
spdlog::debug("Received SIGCHLD in signalThread"); spdlog::debug("Received SIGCHLD in signalThread");
{ {
std::lock_guard<std::mutex> lock(reap_mtx); std::lock_guard<std::mutex> lock(reap_mtx);
for (auto it = reap.begin(); it != reap.end(); ) { for (auto it = reap.begin(); it != reap.end();) {
if (waitpid(*it, nullptr, WNOHANG) == *it) { if (waitpid(*it, nullptr, WNOHANG) == *it) {
spdlog::debug("Reaped child with PID: {}", *it); spdlog::debug("Reaped child with PID: {}", *it);
it = reap.erase(it); it = reap.erase(it);

View File

@ -80,7 +80,8 @@ std::tuple<std::vector<uint16_t>, std::string> waybar::modules::CpuUsage::getCpu
auto [prev_idle, prev_total] = prev_times[0]; auto [prev_idle, prev_total] = prev_times[0];
const float delta_idle = curr_idle - prev_idle; const float delta_idle = curr_idle - prev_idle;
const float delta_total = curr_total - prev_total; const float delta_total = curr_total - prev_total;
uint16_t tmp = (delta_total > 0) ? static_cast<uint16_t>(100 * (1 - delta_idle / delta_total)) : 0; uint16_t tmp =
(delta_total > 0) ? static_cast<uint16_t>(100 * (1 - delta_idle / delta_total)) : 0;
tooltip = fmt::format("Total: {}%\nCores: (pending)", tmp); tooltip = fmt::format("Total: {}%\nCores: (pending)", tmp);
usage.push_back(tmp); usage.push_back(tmp);
} else { } else {
@ -102,7 +103,8 @@ std::tuple<std::vector<uint16_t>, std::string> waybar::modules::CpuUsage::getCpu
} }
const float delta_idle = curr_idle - prev_idle; const float delta_idle = curr_idle - prev_idle;
const float delta_total = curr_total - prev_total; const float delta_total = curr_total - prev_total;
uint16_t tmp = (delta_total > 0) ? static_cast<uint16_t>(100 * (1 - delta_idle / delta_total)) : 0; uint16_t tmp =
(delta_total > 0) ? static_cast<uint16_t>(100 * (1 - delta_idle / delta_total)) : 0;
if (i == 0) { if (i == 0) {
tooltip = fmt::format("Total: {}%", tmp); tooltip = fmt::format("Total: {}%", tmp);
} else { } else {

View File

@ -102,8 +102,8 @@ Sndio::~Sndio() { sioctl_close(hdl_); }
auto Sndio::update() -> void { auto Sndio::update() -> void {
auto format = format_; auto format = format_;
unsigned int vol = (maxval_ > 0) unsigned int vol = (maxval_ > 0) ? static_cast<unsigned int>(100. * static_cast<double>(volume_) /
? static_cast<unsigned int>(100. * static_cast<double>(volume_) / static_cast<double>(maxval_)) static_cast<double>(maxval_))
: 0; : 0;
if (volume_ == 0) { if (volume_ == 0) {

View File

@ -62,7 +62,8 @@ UPower::UPower(const std::string& id, const Json::Value& config)
GError* gErr = NULL; GError* gErr = NULL;
upClient_ = up_client_new_full(NULL, &gErr); upClient_ = up_client_new_full(NULL, &gErr);
if (upClient_ == NULL) { if (upClient_ == NULL) {
spdlog::error("Upower. UPower client connection error. {}", gErr ? gErr->message : "unknown error"); spdlog::error("Upower. UPower client connection error. {}",
gErr ? gErr->message : "unknown error");
if (gErr) g_error_free(gErr); if (gErr) g_error_free(gErr);
} }

View File

@ -79,20 +79,38 @@ static void upsert_device(std::vector<BacklightDevice>& devices, udev_device* de
}); });
if (found != devices.end()) { if (found != devices.end()) {
if (actual != nullptr) { if (actual != nullptr) {
try { found->set_actual(std::stoi(actual)); } catch (const std::exception&) {} try {
found->set_actual(std::stoi(actual));
} catch (const std::exception&) {
}
} }
if (max != nullptr) { if (max != nullptr) {
try { found->set_max(std::stoi(max)); } catch (const std::exception&) {} try {
found->set_max(std::stoi(max));
} catch (const std::exception&) {
}
} }
if (power != nullptr) { if (power != nullptr) {
try { found->set_powered(std::stoi(power) == 0); } catch (const std::exception&) {} try {
found->set_powered(std::stoi(power) == 0);
} catch (const std::exception&) {
}
} }
} else { } else {
int actual_int = 0, max_int = 0; int actual_int = 0, max_int = 0;
bool power_bool = true; bool power_bool = true;
try { if (actual != nullptr) actual_int = std::stoi(actual); } catch (const std::exception&) {} try {
try { if (max != nullptr) max_int = std::stoi(max); } catch (const std::exception&) {} if (actual != nullptr) actual_int = std::stoi(actual);
try { if (power != nullptr) power_bool = std::stoi(power) == 0; } catch (const std::exception&) {} } catch (const std::exception&) {
}
try {
if (max != nullptr) max_int = std::stoi(max);
} catch (const std::exception&) {
}
try {
if (power != nullptr) power_bool = std::stoi(power) == 0;
} catch (const std::exception&) {
}
devices.emplace_back(name, actual_int, max_int, power_bool); devices.emplace_back(name, actual_int, max_int, power_bool);
} }
} }

View File

@ -63,7 +63,8 @@ void waybar::Portal::refreshAppearance() {
Glib::VariantBase modev; Glib::VariantBase modev;
container.get_child(modev, 0); container.get_child(modev, 0);
auto mode = auto mode =
Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::Variant<Glib::Variant<uint32_t>>>>(modev) Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::Variant<Glib::Variant<uint32_t>>>>(
modev)
.get() .get()
.get() .get()
.get(); .get();