summaryrefslogtreecommitdiff
path: root/src/debug/HyprCtl.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-04-20 23:59:31 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-04-20 23:59:31 +0100
commit510db64860fa307e33db5fdb843c6cc5a428b5a4 (patch)
tree67ba9f40af6e260747af708345f3045d82b87e74 /src/debug/HyprCtl.cpp
parentb15803510c67b7b89090c99f03781d9052c959f5 (diff)
hyprctl: allow spaces in cursor themes
Diffstat (limited to 'src/debug/HyprCtl.cpp')
-rw-r--r--src/debug/HyprCtl.cpp47
1 files changed, 15 insertions, 32 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 0603b182..4153a2d2 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -804,47 +804,30 @@ std::string dispatchBatch(std::string request) {
}
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();
+ CVarList vars(request, 0, ' ');
- const auto SIZE = curitem;
+ const auto SIZESTR = vars[vars.size() - 1];
+ std::string theme = "";
+ for (size_t i = 1; i < vars.size() - 1; ++i)
+ theme += vars[i] + " ";
+ theme.pop_back();
- if (!isNumber(SIZE)) {
+ int size = 0;
+ try {
+ size = std::stoi(SIZESTR);
+ } catch (...) {
return "size not int";
}
- const auto SIZEINT = std::stoi(SIZE);
-
- if (SIZEINT < 1) {
- return "size must be positive";
- }
+ if (size <= 0)
+ return "size not positive";
wlr_xcursor_manager_destroy(g_pCompositor->m_sWLRXCursorMgr);
- g_pCompositor->m_sWLRXCursorMgr = wlr_xcursor_manager_create(THEME.c_str(), SIZEINT);
+ g_pCompositor->m_sWLRXCursorMgr = wlr_xcursor_manager_create(theme.c_str(), size);
- setenv("XCURSOR_SIZE", SIZE.c_str(), true);
- setenv("XCURSOR_THEME", THEME.c_str(), true);
+ setenv("XCURSOR_SIZE", SIZESTR.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);