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);
|
||||
bool tooltipEnabled() const;
|
||||
|
||||
std::vector<int> pid_children_;
|
||||
const std::string name_;
|
||||
const Json::Value &config_;
|
||||
Gtk::EventBox event_box_;
|
||||
@ -54,7 +55,6 @@ class AModule : public IModule {
|
||||
const bool isTooltip;
|
||||
const bool isExpand;
|
||||
bool hasUserEvents_;
|
||||
std::vector<int> pid_;
|
||||
gdouble distance_scrolled_y_;
|
||||
gdouble distance_scrolled_x_;
|
||||
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() {
|
||||
for (const auto& pid : pid_) {
|
||||
for (const auto& pid : pid_children_) {
|
||||
if (pid != -1) {
|
||||
killpg(pid, SIGTERM);
|
||||
}
|
||||
@ -93,7 +93,7 @@ AModule::~AModule() {
|
||||
auto AModule::update() -> void {
|
||||
// Run user-provided update handler if configured
|
||||
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
|
||||
@ -182,7 +182,7 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) {
|
||||
format.clear();
|
||||
}
|
||||
if (!format.empty()) {
|
||||
pid_.push_back(util::command::forkExec(format));
|
||||
pid_children_.push_back(util::command::forkExec(format));
|
||||
}
|
||||
dp.emit();
|
||||
return true;
|
||||
@ -267,7 +267,7 @@ bool AModule::handleScroll(GdkEventScroll* e) {
|
||||
this->AModule::doAction(eventName);
|
||||
// Second call user scripts
|
||||
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();
|
||||
return true;
|
||||
|
@ -35,6 +35,13 @@ waybar::modules::Custom::~Custom() {
|
||||
|
||||
void waybar::modules::Custom::delayWorker() {
|
||||
thread_ = [this] {
|
||||
for (int i: this->pid_children_) {
|
||||
int status;
|
||||
waitpid(i, &status, 0);
|
||||
}
|
||||
|
||||
this->pid_children_.clear();
|
||||
|
||||
bool can_update = true;
|
||||
if (config_["exec-if"].isString()) {
|
||||
output_ = util::command::execNoRead(config_["exec-if"].asString());
|
||||
|
Reference in New Issue
Block a user