feat: allow not switching output when clicking sway/workspace

This commit is contained in:
Axel Dahlberg
2025-12-07 19:43:25 +01:00
parent 161367d961
commit 7777be0da6
2 changed files with 18 additions and 5 deletions
+4
View File
@@ -78,6 +78,10 @@ Addressed by *sway/workspaces*
typeof: bool ++
Whether to disable *workspace_auto_back_and_forth* when clicking on workspaces. If this is set to *true*, clicking on a workspace you are already on won't do anything, even if *workspace_auto_back_and_forth* is enabled in the Sway configuration.
*no-switch-output*: ++
typeof: bool ++
Whether to disable switching output when clicking on workspaces. If this is set to *true*, then clicking on a workspace on a different output will bring it to the current output instead of switching to that output.
*alphabetical_sort*: ++
typeof: bool ++
Whether to sort workspaces alphabetically. Please note this can make "swaymsg workspace prev/next" move to workspaces inconsistent with the ordering shown in Waybar.
+14 -5
View File
@@ -369,11 +369,20 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
node["name"].asString(), node["target_output"].asString(),
"--no-auto-back-and-forth", node["name"].asString()));
} else {
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace {} \"{}\"",
config_["disable-auto-back-and-forth"].asBool()
? "--no-auto-back-and-forth"
: "",
node["name"].asString()));
if (config_["no-switch-output"].asBool()) {
ipc_.sendCmd(IPC_COMMAND, fmt::format("[workspace=\"^{}$\"] move workspace to output current; workspace number {} \"{}\"",
node["name"].asString(),
config_["disable-auto-back-and-forth"].asBool()
? "--no-auto-back-and-forth"
: "",
node["name"].asString()));
} else {
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace {} \"{}\"",
config_["disable-auto-back-and-forth"].asBool()
? "--no-auto-back-and-forth"
: "",
node["name"].asString()));
}
}
} catch (const std::exception &e) {
spdlog::error("Workspaces: {}", e.what());