refactor: also pass id to custom modules
This commit is contained in:
parent
e999cca7a6
commit
9e1200ae32
|
@ -12,7 +12,7 @@ namespace waybar::modules {
|
||||||
|
|
||||||
class Custom : public ALabel {
|
class Custom : public ALabel {
|
||||||
public:
|
public:
|
||||||
Custom(const std::string&, const Json::Value&);
|
Custom(const std::string&, const std::string&, const Json::Value&);
|
||||||
~Custom();
|
~Custom();
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
void refresh(int /*signal*/);
|
void refresh(int /*signal*/);
|
||||||
|
|
|
@ -64,7 +64,7 @@ waybar::IModule* waybar::Factory::makeModule(const std::string& name) const {
|
||||||
return new waybar::modules::Temperature(id, config_[name]);
|
return new waybar::modules::Temperature(id, config_[name]);
|
||||||
}
|
}
|
||||||
if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) {
|
if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) {
|
||||||
return new waybar::modules::Custom(ref.substr(7), config_[name]);
|
return new waybar::modules::Custom(ref.substr(7), id, config_[name]);
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
auto err = fmt::format("Disabling module \"{}\", {}", name, e.what());
|
auto err = fmt::format("Disabling module \"{}\", {}", name, e.what());
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#include "modules/custom.hpp"
|
#include "modules/custom.hpp"
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
waybar::modules::Custom::Custom(const std::string& name, const Json::Value& config)
|
waybar::modules::Custom::Custom(const std::string& name, const std::string& id,
|
||||||
: ALabel(config, "custom-" + name_, name, "{}"), name_(name), fp_(nullptr), pid_(-1) {
|
const Json::Value& config)
|
||||||
|
: ALabel(config, "custom-" + name_, id, "{}"), name_(name), fp_(nullptr), pid_(-1) {
|
||||||
if (config_["exec"].isString()) {
|
if (config_["exec"].isString()) {
|
||||||
if (interval_.count() > 0) {
|
if (interval_.count() > 0) {
|
||||||
delayWorker();
|
delayWorker();
|
||||||
|
|
Loading…
Reference in New Issue