From 11fdbe8ae3b0de90119ff53a7681562c36c34f83 Mon Sep 17 00:00:00 2001 From: Lena Date: Tue, 14 Oct 2025 13:42:48 +0200 Subject: [PATCH] clang-format --- include/modules/wwan.hpp | 38 +++++++++++++++---------------- src/modules/wwan.cpp | 48 ++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/include/modules/wwan.hpp b/include/modules/wwan.hpp index 8b18e999..4ef851af 100644 --- a/include/modules/wwan.hpp +++ b/include/modules/wwan.hpp @@ -1,39 +1,37 @@ #pragma once #include +#include #include #include -#include - #include "ALabel.hpp" #include "util/format.hpp" #include "util/sleeper_thread.hpp" namespace waybar::modules { - class Wwan : public ALabel { - public: - Wwan(const std::string&, const Json::Value&); - virtual ~Wwan(); - auto update() -> void override; +class Wwan : public ALabel { + public: + Wwan(const std::string&, const Json::Value&); + virtual ~Wwan(); + auto update() -> void override; - private: + private: + void updateCurrentModem(); - void updateCurrentModem(); + util::SleeperThread thread_; + std::string state_; + GDBusConnection* connection; + MMManager* manager; + MMModem* current_modem; - util::SleeperThread thread_; - std::string state_; - GDBusConnection* connection; - MMManager* manager; - MMModem* current_modem; + bool hideDisconnected = true; - bool hideDisconnected = true; - - const std::string dbus_name = "org.freedesktop.ModemManager1"; - const std::string dbus_obj_path = "/org/freedesktop/ModemManager1/"; - const std::string dbus_modems_path = "/org/freedesktop/ModemManager1/Modems/"; - }; + const std::string dbus_name = "org.freedesktop.ModemManager1"; + const std::string dbus_obj_path = "/org/freedesktop/ModemManager1/"; + const std::string dbus_modems_path = "/org/freedesktop/ModemManager1/Modems/"; +}; } // namespace waybar::modules diff --git a/src/modules/wwan.cpp b/src/modules/wwan.cpp index 5a328a73..8cd3aefe 100644 --- a/src/modules/wwan.cpp +++ b/src/modules/wwan.cpp @@ -1,8 +1,10 @@ #include "modules/wwan.hpp" + #include #include #include + #include "ModemManager.h" #include "libmm-glib.h" @@ -16,13 +18,12 @@ #endif namespace { - using namespace waybar::util; - constexpr const char *DEFAULT_FORMAT = "{state}"; +using namespace waybar::util; +constexpr const char* DEFAULT_FORMAT = "{state}"; } // namespace - waybar::modules::Wwan::Wwan(const std::string& id, const Json::Value& config) -: ALabel(config, "wwan", id, "{}", 5) { + : ALabel(config, "wwan", id, "{}", 5) { thread_ = [this] { dp.emit(); thread_.sleep_for(interval_); @@ -35,13 +36,9 @@ waybar::modules::Wwan::Wwan(const std::string& id, const Json::Value& config) return; } - - manager = mm_manager_new_sync( - connection, - G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, - nullptr, // cancellable - &error - ); + manager = mm_manager_new_sync(connection, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, + nullptr, // cancellable + &error); if (error) { spdlog::error("Failed to create ModemManager proxy: " + std::string(error->message)); @@ -55,10 +52,9 @@ waybar::modules::Wwan::Wwan(const std::string& id, const Json::Value& config) if (config_["hide-disconnected"].isBool()) { hideDisconnected = config_["hide-disconnected"].asBool(); } - } -void waybar::modules::Wwan::updateCurrentModem(){ +void waybar::modules::Wwan::updateCurrentModem() { // get 1st modem (or modem with the specified hardware path) GList* modems = g_dbus_object_manager_get_objects(G_DBUS_OBJECT_MANAGER(manager)); @@ -75,7 +71,7 @@ void waybar::modules::Wwan::updateCurrentModem(){ std::string path = config_["path"].asString(); std::string other = mm_modem_dup_physdev(modem); - if(path != other) { + if (path != other) { g_object_unref(modem); modem = nullptr; continue; @@ -86,7 +82,7 @@ void waybar::modules::Wwan::updateCurrentModem(){ std::string imei = config_["imei"].asString(); std::string other = mm_modem_dup_equipment_identifier(modem); - if(imei != other) { + if (imei != other) { g_object_unref(modem); modem = nullptr; continue; @@ -155,7 +151,6 @@ std::string getModemStateFormatString(MMModem* modem) { } std::string getPreferredModeString(MMModem* modem) { - MMModemModeCombination combination; mm_modem_get_current_modes(modem, &combination.allowed, &combination.preferred); @@ -175,27 +170,20 @@ std::string getPreferredModeString(MMModem* modem) { } } - std::string getCurrentModesString(MMModem* modem) { - MMModemModeCombination combination; mm_modem_get_current_modes(modem, &combination.allowed, &combination.preferred); std::string buffer; - if(combination.allowed & MMModemMode::MM_MODEM_MODE_CS) - buffer += "CS | "; - if(combination.allowed & MMModemMode::MM_MODEM_MODE_2G) - buffer += "2G | "; - if(combination.allowed & MMModemMode::MM_MODEM_MODE_3G) - buffer += "3G | "; - if(combination.allowed & MMModemMode::MM_MODEM_MODE_4G) - buffer += "4G | "; - if(combination.allowed & MMModemMode::MM_MODEM_MODE_5G) - buffer += "5G | "; + if (combination.allowed & MMModemMode::MM_MODEM_MODE_CS) buffer += "CS | "; + if (combination.allowed & MMModemMode::MM_MODEM_MODE_2G) buffer += "2G | "; + if (combination.allowed & MMModemMode::MM_MODEM_MODE_3G) buffer += "3G | "; + if (combination.allowed & MMModemMode::MM_MODEM_MODE_4G) buffer += "4G | "; + if (combination.allowed & MMModemMode::MM_MODEM_MODE_5G) buffer += "5G | "; if (buffer.length() > 2) { - buffer.erase(buffer.length()-2); + buffer.erase(buffer.length() - 2); } return buffer; } @@ -216,7 +204,6 @@ std::string getPowerStateString(MMModem* modem) { } std::string getOperatorNameString(MMModem* modem) { - MMSim* sim = mm_modem_get_sim_sync(modem, nullptr, nullptr); if (sim == nullptr) { @@ -268,7 +255,6 @@ auto waybar::modules::Wwan::update() -> void { state_ = state; } - auto format = format_; fmt::dynamic_format_arg_store store;