Skip to content

Commit

Permalink
Issue 3284: deal with "sh: line 1: activate not found"
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertMueller2 committed Jul 7, 2024
1 parent b26ab1f commit 638a74a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
2 changes: 2 additions & 0 deletions include/modules/wlr/taskbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Taskbar : public waybar::AModule {
Taskbar(const std::string &, const waybar::Bar &, const Json::Value &);
~Taskbar();
void update();
auto doAction(const std::string &) -> void override;

private:
const waybar::Bar &bar_;
Expand Down Expand Up @@ -170,6 +171,7 @@ class Taskbar : public waybar::AModule {

bool show_output(struct wl_output *) const;
bool all_outputs() const;
bool legacy_event_config = false;

const std::vector<Glib::RefPtr<Gtk::IconTheme>> &icon_themes() const;
const std::unordered_set<std::string> &ignore_list() const;
Expand Down
12 changes: 7 additions & 5 deletions man/waybar-wlr-taskbar.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ Addressed by *wlr/taskbar*

*on-click*: ++
typeof: string ++
The action which should be triggered when clicking on the application button with the left mouse button.
The action which should be triggered when clicking on the application button with the left mouse button. Needs to be defined in actions object.

*on-click-middle*: ++
typeof: string ++
The action which should be triggered when clicking on the application button with the middle mouse button.
The action which should be triggered when clicking on the application button with the middle mouse button. Needs to be defined in actions object.

*on-click-right*: ++
typeof: string ++
The action which should be triggered when clicking on the application button with the right mouse button.
The action which should be triggered when clicking on the application button with the right mouse button. Needs to be defined in actions object.

*on-update*: ++
typeof: string ++
Expand Down Expand Up @@ -133,8 +133,10 @@ Invalid expressions (e.g., mismatched parentheses) are skipped.
"icon-size": 14,
"icon-theme": "Numix-Circle",
"tooltip-format": "{title}",
"on-click": "activate",
"on-click-middle": "close",
"actions" : {
"on-click": "activate",
"on-click-middle": "close",
},
"ignore-list": [
"Alacritty"
],
Expand Down
40 changes: 29 additions & 11 deletions src/modules/wlr/taskbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,6 @@ Task::Task(const waybar::Bar &bar, const Json::Value &config, Taskbar *tbar,
format_tooltip_ = "{title}";
}

/* Handle click events if configured */
if (config_["on-click"].isString() || config_["on-click-middle"].isString() ||
config_["on-click-right"].isString()) {
}

button.add_events(Gdk::BUTTON_PRESS_MASK);
button.signal_button_release_event().connect(sigc::mem_fun(*this, &Task::handle_clicked), false);

Expand Down Expand Up @@ -542,12 +537,20 @@ bool Task::handle_clicked(GdkEventButton *bt) {
}

std::string action;
if (config_["on-click"].isString() && bt->button == 1)
action = config_["on-click"].asString();
else if (config_["on-click-middle"].isString() && bt->button == 2)
action = config_["on-click-middle"].asString();
else if (config_["on-click-right"].isString() && bt->button == 3)
action = config_["on-click-right"].asString();
auto cr = config_["actions"];
if (!cr.isObject()) {
if (tbar_->legacy_event_config) {
cr = config_;
} else {
return false;
}
}
if (cr["on-click"].isString() && bt->button == 1)
action = cr["on-click"].asString();
else if (cr["on-click-middle"].isString() && bt->button == 2)
action = cr["on-click-middle"].asString();
else if (cr["on-click-right"].isString() && bt->button == 3)
action = cr["on-click-right"].asString();

if (action.empty())
return true;
Expand Down Expand Up @@ -787,6 +790,19 @@ Taskbar::Taskbar(const std::string &id, const waybar::Bar &bar, const Json::Valu
}
}

if (config_["on-click"]) {
legacy_event_config = true;
spdlog::warn("wlr/taskbar: on-click should be within actions object");
}
if (config_["on-click-right"]) {
legacy_event_config = true;
spdlog::warn("wlr/taskbar: on-click-right should be within actions object");
}
if (config_["on-click-middle"]) {
legacy_event_config = true;
spdlog::warn("wlr/taskbar: on-click-middle should be within actions object");
}

icon_themes_.push_back(Gtk::IconTheme::get_default());

for (auto &t : tasks_) {
Expand Down Expand Up @@ -846,6 +862,8 @@ static const struct zwlr_foreign_toplevel_manager_v1_listener toplevel_manager_i
.finished = tm_handle_finished,
};

auto Taskbar::doAction(const std::string &name) -> void {}

void Taskbar::register_manager(struct wl_registry *registry, uint32_t name, uint32_t version) {
if (manager_) {
spdlog::warn("Register foreign toplevel manager again although already existing!");
Expand Down

0 comments on commit 638a74a

Please sign in to comment.