fix(sway/workspaces): use number when available to avoid parsing issues
This commit is contained in:
@@ -23,7 +23,8 @@ class Workspaces : public AModule, public sigc::trackable {
|
|||||||
auto update() -> void override;
|
auto update() -> void override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr std::string_view workspace_switch_cmd_ = "workspace {} {}";
|
static constexpr std::string_view workspace_switch_cmd_ = "workspace {} \"{}\"";
|
||||||
|
static constexpr std::string_view workspace_switch_number_cmd_ = "workspace {} number {}";
|
||||||
static constexpr std::string_view persistent_workspace_switch_cmd_ =
|
static constexpr std::string_view persistent_workspace_switch_cmd_ =
|
||||||
R"(workspace {} "{}"; move workspace to output "{}"; workspace {} "{}")";
|
R"(workspace {} "{}"; move workspace to output "{}"; workspace {} "{}")";
|
||||||
|
|
||||||
|
|||||||
@@ -369,11 +369,14 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
|
|||||||
node["name"].asString(), node["target_output"].asString(),
|
node["name"].asString(), node["target_output"].asString(),
|
||||||
"--no-auto-back-and-forth", node["name"].asString()));
|
"--no-auto-back-and-forth", node["name"].asString()));
|
||||||
} else {
|
} else {
|
||||||
ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_,
|
std::string flag = config_["disable-auto-back-and-forth"].asBool()
|
||||||
config_["disable-auto-back-and-forth"].asBool()
|
|
||||||
? "--no-auto-back-and-forth"
|
? "--no-auto-back-and-forth"
|
||||||
: "",
|
: "";
|
||||||
node["name"].asString()));
|
if (node["num"].asInt() >= 0) {
|
||||||
|
ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_number_cmd_, flag, node["num"].asInt()));
|
||||||
|
} else {
|
||||||
|
ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_, flag, node["name"].asString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
spdlog::error("Workspaces: {}", e.what());
|
spdlog::error("Workspaces: {}", e.what());
|
||||||
|
|||||||
Reference in New Issue
Block a user