custom: Add "exec-on-event" config

This config allows disabling the default behavior of re-executing the
script whenever an event that has a command set is triggered.

Fixes #841
This commit is contained in:
Tamir Zahavi-Brunner
2020-09-06 22:47:34 +03:00
parent 44119db436
commit 9e3e4368c7
3 changed files with 15 additions and 2 deletions

View File

@ -91,15 +91,21 @@ void waybar::modules::Custom::refresh(int sig) {
}
}
void waybar::modules::Custom::handleEvent() {
if (!config_["exec-on-event"].isBool() || config_["exec-on-event"].asBool()) {
thread_.wake_up();
}
}
bool waybar::modules::Custom::handleScroll(GdkEventScroll* e) {
auto ret = ALabel::handleScroll(e);
thread_.wake_up();
handleEvent();
return ret;
}
bool waybar::modules::Custom::handleToggle(GdkEventButton* const& e) {
auto ret = ALabel::handleToggle(e);
thread_.wake_up();
handleEvent();
return ret;
}