Merge pull request #1784 from ruanformigoni/issue-1681
exec runs after on-* events
This commit is contained in:
@ -36,6 +36,7 @@ class AModule : public IModule {
|
|||||||
SCROLL_DIR getScrollDir(GdkEventScroll *e);
|
SCROLL_DIR getScrollDir(GdkEventScroll *e);
|
||||||
bool tooltipEnabled() const;
|
bool tooltipEnabled() const;
|
||||||
|
|
||||||
|
std::vector<int> pid_children_;
|
||||||
const std::string name_;
|
const std::string name_;
|
||||||
const Json::Value &config_;
|
const Json::Value &config_;
|
||||||
Gtk::EventBox event_box_;
|
Gtk::EventBox event_box_;
|
||||||
@ -54,7 +55,6 @@ class AModule : public IModule {
|
|||||||
const bool isTooltip;
|
const bool isTooltip;
|
||||||
const bool isExpand;
|
const bool isExpand;
|
||||||
bool hasUserEvents_;
|
bool hasUserEvents_;
|
||||||
std::vector<int> pid_;
|
|
||||||
gdouble distance_scrolled_y_;
|
gdouble distance_scrolled_y_;
|
||||||
gdouble distance_scrolled_x_;
|
gdouble distance_scrolled_x_;
|
||||||
std::map<std::string, std::string> eventActionMap_;
|
std::map<std::string, std::string> eventActionMap_;
|
||||||
|
@ -83,7 +83,7 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
|||||||
}
|
}
|
||||||
|
|
||||||
AModule::~AModule() {
|
AModule::~AModule() {
|
||||||
for (const auto& pid : pid_) {
|
for (const auto& pid : pid_children_) {
|
||||||
if (pid != -1) {
|
if (pid != -1) {
|
||||||
killpg(pid, SIGTERM);
|
killpg(pid, SIGTERM);
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ AModule::~AModule() {
|
|||||||
auto AModule::update() -> void {
|
auto AModule::update() -> void {
|
||||||
// Run user-provided update handler if configured
|
// Run user-provided update handler if configured
|
||||||
if (config_["on-update"].isString()) {
|
if (config_["on-update"].isString()) {
|
||||||
pid_.push_back(util::command::forkExec(config_["on-update"].asString()));
|
pid_children_.push_back(util::command::forkExec(config_["on-update"].asString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get mapping between event name and module action name
|
// Get mapping between event name and module action name
|
||||||
@ -182,7 +182,7 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) {
|
|||||||
format.clear();
|
format.clear();
|
||||||
}
|
}
|
||||||
if (!format.empty()) {
|
if (!format.empty()) {
|
||||||
pid_.push_back(util::command::forkExec(format));
|
pid_children_.push_back(util::command::forkExec(format));
|
||||||
}
|
}
|
||||||
dp.emit();
|
dp.emit();
|
||||||
return true;
|
return true;
|
||||||
@ -267,7 +267,7 @@ bool AModule::handleScroll(GdkEventScroll* e) {
|
|||||||
this->AModule::doAction(eventName);
|
this->AModule::doAction(eventName);
|
||||||
// Second call user scripts
|
// Second call user scripts
|
||||||
if (config_[eventName].isString())
|
if (config_[eventName].isString())
|
||||||
pid_.push_back(util::command::forkExec(config_[eventName].asString()));
|
pid_children_.push_back(util::command::forkExec(config_[eventName].asString()));
|
||||||
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
return true;
|
return true;
|
||||||
|
@ -35,6 +35,13 @@ waybar::modules::Custom::~Custom() {
|
|||||||
|
|
||||||
void waybar::modules::Custom::delayWorker() {
|
void waybar::modules::Custom::delayWorker() {
|
||||||
thread_ = [this] {
|
thread_ = [this] {
|
||||||
|
for (int i: this->pid_children_) {
|
||||||
|
int status;
|
||||||
|
waitpid(i, &status, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->pid_children_.clear();
|
||||||
|
|
||||||
bool can_update = true;
|
bool can_update = true;
|
||||||
if (config_["exec-if"].isString()) {
|
if (config_["exec-if"].isString()) {
|
||||||
output_ = util::command::execNoRead(config_["exec-if"].asString());
|
output_ = util::command::execNoRead(config_["exec-if"].asString());
|
||||||
|
Reference in New Issue
Block a user