mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor: kill custom modules scripts en destroy
This commit is contained in:
@ -3,7 +3,11 @@
|
||||
|
||||
waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar& bar,
|
||||
const Json::Value& config)
|
||||
: ALabel(config, "{status}"), bar_(bar), status_("deactivated"), idle_inhibitor_(nullptr) {
|
||||
: ALabel(config, "{status}"),
|
||||
bar_(bar),
|
||||
status_("deactivated"),
|
||||
idle_inhibitor_(nullptr),
|
||||
pid_(-1) {
|
||||
label_.set_name("idle_inhibitor");
|
||||
if (!id.empty()) {
|
||||
label_.get_style_context()->add_class(id);
|
||||
@ -19,6 +23,10 @@ waybar::modules::IdleInhibitor::~IdleInhibitor() {
|
||||
zwp_idle_inhibitor_v1_destroy(idle_inhibitor_);
|
||||
idle_inhibitor_ = nullptr;
|
||||
}
|
||||
if (pid_ != -1) {
|
||||
kill(-pid_, 9);
|
||||
pid_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
auto waybar::modules::IdleInhibitor::update() -> void {
|
||||
@ -43,7 +51,7 @@ bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
||||
status_ = "activated";
|
||||
}
|
||||
if (config_["on-click"].isString() && e->button == 1) {
|
||||
waybar::util::command::forkExec(config_["on-click"].asString());
|
||||
pid_ = waybar::util::command::forkExec(config_["on-click"].asString());
|
||||
}
|
||||
} else {
|
||||
ALabel::handleToggle(e);
|
||||
|
Reference in New Issue
Block a user