fix(custom): avoid hide outside update

This commit is contained in:
Alex 2020-05-25 09:21:04 +02:00
parent 1d92d78de7
commit 3b16946c25

View File

@ -1,18 +1,15 @@
#include "modules/custom.hpp"
#include <spdlog/spdlog.h>
waybar::modules::Custom::Custom(const std::string& name, const std::string& id,
const Json::Value& config)
: ALabel(config, "custom-" + name, id, "{}"), name_(name), fp_(nullptr), pid_(-1) {
// Hide box by default
event_box_.hide();
dp.emit();
if (interval_.count() > 0) {
delayWorker();
} else if (config_["exec"].isString()) {
continuousWorker();
} else {
dp.emit();
}
}
@ -30,7 +27,7 @@ void waybar::modules::Custom::delayWorker() {
output_ = util::command::execNoRead(config_["exec-if"].asString());
if (output_.exit_code != 0) {
can_update = false;
event_box_.hide();
dp.emit();
}
}
if (can_update) {
@ -112,7 +109,8 @@ bool waybar::modules::Custom::handleToggle(GdkEventButton* const& e) {
auto waybar::modules::Custom::update() -> void {
// Hide label if output is empty
if (config_["exec"].isString() && (output_.out.empty() || output_.exit_code != 0)) {
if ((config_["exec"].isString() || config_["exec-if"].isString()) &&
(output_.out.empty() || output_.exit_code != 0)) {
event_box_.hide();
} else {
if (config_["return-type"].asString() == "json") {