feat: dispatcher, add workspace renaming (#1336)

* feat: dispatcher, add workspace renaming

Co-authored-by: vaxerski <vaxry@vaxry.net>
This commit is contained in:
Cyril Levis
2023-01-08 14:19:18 +01:00
committed by GitHub
parent b1104b1ca7
commit 3173fbdc4a
4 changed files with 33 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["closewindow"] = kill;
m_mDispatchers["togglefloating"] = toggleActiveFloating;
m_mDispatchers["workspace"] = changeworkspace;
m_mDispatchers["renameworkspace"] = renameWorkspace;
m_mDispatchers["fullscreen"] = fullscreenActive;
m_mDispatchers["fakefullscreen"] = fakeFullscreenActive;
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
@@ -1289,6 +1290,21 @@ void CKeybindManager::workspaceOpt(std::string args) {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID);
}
void CKeybindManager::renameWorkspace(std::string args) {
try {
const auto FIRSTSPACEPOS = args.find_first_of(' ');
if (FIRSTSPACEPOS != std::string::npos) {
int workspace = std::stoi(args.substr(0, FIRSTSPACEPOS));
std::string name = args.substr(FIRSTSPACEPOS + 1);
g_pCompositor->renameWorkspace(workspace, name);
} else {
g_pCompositor->renameWorkspace(std::stoi(args), "");
}
} catch (std::exception& e) {
Debug::log(ERR, "Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. \"%s\": \"%s\"", args.c_str(), e.what());
}
}
void CKeybindManager::exitHyprland(std::string argz) {
g_pCompositor->cleanup();
}