chore: lint
parent
1dce607c42
commit
fb6658e8fd
|
@ -1,15 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <giomm/dbusproxy.h>
|
#include <giomm/dbusproxy.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "ALabel.hpp"
|
#include "ALabel.hpp"
|
||||||
|
|
||||||
namespace waybar::modules {
|
namespace waybar::modules {
|
||||||
|
|
||||||
class SystemdFailedUnits : public ALabel {
|
class SystemdFailedUnits : public ALabel {
|
||||||
public:
|
public:
|
||||||
SystemdFailedUnits(const std::string&, const Json::Value&);
|
SystemdFailedUnits(const std::string &, const Json::Value &);
|
||||||
virtual ~SystemdFailedUnits();
|
virtual ~SystemdFailedUnits();
|
||||||
auto update() -> void override;
|
auto update() -> void override;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "modules/battery.hpp"
|
#include "modules/battery.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
@ -696,17 +697,16 @@ void waybar::modules::Battery::setBarClass(std::string& state) {
|
||||||
auto classes = bar_.window.get_style_context()->list_classes();
|
auto classes = bar_.window.get_style_context()->list_classes();
|
||||||
const std::string prefix = "battery-";
|
const std::string prefix = "battery-";
|
||||||
|
|
||||||
auto old_class_it = std::find_if(classes.begin(), classes.end(),
|
auto old_class_it = std::find_if(classes.begin(), classes.end(), [&prefix](auto classname) {
|
||||||
[&prefix](auto classname) {
|
return classname.rfind(prefix, 0) == 0;
|
||||||
return classname.rfind(prefix, 0) == 0;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
auto new_class = prefix + state;
|
auto new_class = prefix + state;
|
||||||
|
|
||||||
// If the bar doesn't have any `battery-` class
|
// If the bar doesn't have any `battery-` class
|
||||||
if(old_class_it == classes.end()) {
|
if (old_class_it == classes.end()) {
|
||||||
if(!state.empty()) {
|
if (!state.empty()) {
|
||||||
bar_.window.get_style_context()->add_class(new_class);
|
bar_.window.get_style_context()->add_class(new_class);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -715,14 +715,14 @@ void waybar::modules::Battery::setBarClass(std::string& state) {
|
||||||
|
|
||||||
// If the bar has a `battery-` class,
|
// If the bar has a `battery-` class,
|
||||||
// but `state` is empty
|
// but `state` is empty
|
||||||
if(state.empty()) {
|
if (state.empty()) {
|
||||||
bar_.window.get_style_context()->remove_class(old_class);
|
bar_.window.get_style_context()->remove_class(old_class);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the bar has a `battery-` class,
|
// If the bar has a `battery-` class,
|
||||||
// and `state` is NOT empty
|
// and `state` is NOT empty
|
||||||
if(old_class != new_class) {
|
if (old_class != new_class) {
|
||||||
bar_.window.get_style_context()->remove_class(old_class);
|
bar_.window.get_style_context()->remove_class(old_class);
|
||||||
bar_.window.get_style_context()->add_class(new_class);
|
bar_.window.get_style_context()->add_class(new_class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#include "modules/systemd_failed_units.hpp"
|
#include "modules/systemd_failed_units.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <giomm/dbusproxy.h>
|
#include <giomm/dbusproxy.h>
|
||||||
#include <glibmm/variant.h>
|
#include <glibmm/variant.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
static const unsigned UPDATE_DEBOUNCE_TIME_MS = 1000;
|
static const unsigned UPDATE_DEBOUNCE_TIME_MS = 1000;
|
||||||
|
|
||||||
namespace waybar::modules {
|
namespace waybar::modules {
|
||||||
|
@ -55,23 +56,21 @@ SystemdFailedUnits::~SystemdFailedUnits() {
|
||||||
if (user_proxy) user_proxy.reset();
|
if (user_proxy) user_proxy.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SystemdFailedUnits::notify_cb(
|
auto SystemdFailedUnits::notify_cb(const Glib::ustring& sender_name,
|
||||||
const Glib::ustring &sender_name,
|
const Glib::ustring& signal_name,
|
||||||
const Glib::ustring &signal_name,
|
const Glib::VariantContainerBase& arguments) -> void {
|
||||||
const Glib::VariantContainerBase &arguments) -> void {
|
|
||||||
if (signal_name == "PropertiesChanged" && !update_pending) {
|
if (signal_name == "PropertiesChanged" && !update_pending) {
|
||||||
update_pending = true;
|
update_pending = true;
|
||||||
/* The fail count may fluctuate due to restarting. */
|
/* The fail count may fluctuate due to restarting. */
|
||||||
Glib::signal_timeout().connect_once(
|
Glib::signal_timeout().connect_once(sigc::mem_fun(*this, &SystemdFailedUnits::updateData),
|
||||||
sigc::mem_fun(*this, &SystemdFailedUnits::updateData),
|
UPDATE_DEBOUNCE_TIME_MS);
|
||||||
UPDATE_DEBOUNCE_TIME_MS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemdFailedUnits::updateData() {
|
void SystemdFailedUnits::updateData() {
|
||||||
update_pending = false;
|
update_pending = false;
|
||||||
|
|
||||||
auto load = [](const char* kind, Glib::RefPtr<Gio::DBus::Proxy> &proxy) -> uint32_t {
|
auto load = [](const char* kind, Glib::RefPtr<Gio::DBus::Proxy>& proxy) -> uint32_t {
|
||||||
try {
|
try {
|
||||||
auto parameters = Glib::VariantContainerBase(
|
auto parameters = Glib::VariantContainerBase(
|
||||||
g_variant_new("(ss)", "org.freedesktop.systemd1.Manager", "NFailedUnits"));
|
g_variant_new("(ss)", "org.freedesktop.systemd1.Manager", "NFailedUnits"));
|
||||||
|
@ -123,11 +122,9 @@ auto SystemdFailedUnits::update() -> void {
|
||||||
last_status = status;
|
last_status = status;
|
||||||
|
|
||||||
label_.set_markup(fmt::format(
|
label_.set_markup(fmt::format(
|
||||||
fmt::runtime(nr_failed == 0 ? format_ok : format_),
|
fmt::runtime(nr_failed == 0 ? format_ok : format_), fmt::arg("nr_failed", nr_failed),
|
||||||
fmt::arg("nr_failed", nr_failed),
|
fmt::arg("nr_failed_system", nr_failed_system), fmt::arg("nr_failed_user", nr_failed_user)));
|
||||||
fmt::arg("nr_failed_system", nr_failed_system),
|
|
||||||
fmt::arg("nr_failed_user", nr_failed_user)));
|
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace waybar::modules::systemd_failed_units
|
} // namespace waybar::modules
|
||||||
|
|
Loading…
Reference in New Issue