diff options
| author | vaxerski <vaxry@vaxry.net> | 2022-08-10 21:22:11 +0200 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2022-08-10 21:22:11 +0200 |
| commit | 9b39a0c2e0fb3ad4500c132dc975580f90eb1c08 (patch) | |
| tree | 559cd28307542ec184bfc522131457bcdc79f22d /src/debug/HyprCtl.cpp | |
| parent | f64f94ca565a2ec9f174f57a20fcfbfddb762cb8 (diff) | |
Added hyprctl setcursor
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index cd91955e..714a4f71 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -522,6 +522,56 @@ std::string dispatchBatch(std::string request) { return reply; } +std::string dispatchSetCursor(std::string request) { + std::string curitem = ""; + + auto nextItem = [&]() { + auto idx = request.find_first_of(' '); + + if (idx != std::string::npos) { + curitem = request.substr(0, idx); + request = request.substr(idx + 1); + } else { + curitem = request; + request = ""; + } + + curitem = removeBeginEndSpacesTabs(curitem); + }; + + nextItem(); + nextItem(); + + const auto THEME = curitem; + + nextItem(); + + const auto SIZE = curitem; + + if (!isNumber(SIZE)) { + return "size not int"; + } + + const auto SIZEINT = std::stoi(SIZE); + + if (SIZEINT < 1) { + return "size must be positive"; + } + + wlr_xcursor_manager_destroy(g_pCompositor->m_sWLRXCursorMgr); + + g_pCompositor->m_sWLRXCursorMgr = wlr_xcursor_manager_create(THEME.c_str(), SIZEINT); + + setenv("XCURSOR_SIZE", SIZE.c_str(), true); + setenv("XCURSOR_THEME", THEME.c_str(), true); + + for (auto& m : g_pCompositor->m_vMonitors) { + wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, m->scale); + } + + return "ok"; +} + std::string getReply(std::string request) { auto format = HyprCtl::FORMAT_NORMAL; @@ -567,6 +617,8 @@ std::string getReply(std::string request) { return dispatchRequest(request); else if (request.find("keyword") == 0) return dispatchKeyword(request); + else if (request.find("setcursor") == 0) + return dispatchSetCursor(request); else if (request.find("[[BATCH]]") == 0) return dispatchBatch(request); |
