mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 07:05:58 +01:00
hyprctl: allow spaces in cursor themes
This commit is contained in:
parent
b15803510c
commit
510db64860
2 changed files with 19 additions and 33 deletions
|
@ -227,7 +227,10 @@ int setcursorRequest(int argc, char** argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rq = "setcursor " + std::string(argv[2]) + " " + std::string(argv[3]);
|
std::string rq = "setcursor ";
|
||||||
|
for (size_t i = 2; i < argc; ++i)
|
||||||
|
rq += std::string(argv[i]) + " ";
|
||||||
|
rq.pop_back();
|
||||||
|
|
||||||
request(rq);
|
request(rq);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -804,47 +804,30 @@ std::string dispatchBatch(std::string request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dispatchSetCursor(std::string request) {
|
std::string dispatchSetCursor(std::string request) {
|
||||||
std::string curitem = "";
|
CVarList vars(request, 0, ' ');
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
const auto SIZESTR = vars[vars.size() - 1];
|
||||||
auto idx = request.find_first_of(' ');
|
std::string theme = "";
|
||||||
|
for (size_t i = 1; i < vars.size() - 1; ++i)
|
||||||
|
theme += vars[i] + " ";
|
||||||
|
theme.pop_back();
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
int size = 0;
|
||||||
curitem = request.substr(0, idx);
|
try {
|
||||||
request = request.substr(idx + 1);
|
size = std::stoi(SIZESTR);
|
||||||
} else {
|
} catch (...) {
|
||||||
curitem = request;
|
|
||||||
request = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
curitem = removeBeginEndSpacesTabs(curitem);
|
|
||||||
};
|
|
||||||
|
|
||||||
nextItem();
|
|
||||||
nextItem();
|
|
||||||
|
|
||||||
const auto THEME = curitem;
|
|
||||||
|
|
||||||
nextItem();
|
|
||||||
|
|
||||||
const auto SIZE = curitem;
|
|
||||||
|
|
||||||
if (!isNumber(SIZE)) {
|
|
||||||
return "size not int";
|
return "size not int";
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto SIZEINT = std::stoi(SIZE);
|
if (size <= 0)
|
||||||
|
return "size not positive";
|
||||||
if (SIZEINT < 1) {
|
|
||||||
return "size must be positive";
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_xcursor_manager_destroy(g_pCompositor->m_sWLRXCursorMgr);
|
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_SIZE", SIZESTR.c_str(), true);
|
||||||
setenv("XCURSOR_THEME", THEME.c_str(), true);
|
setenv("XCURSOR_THEME", theme.c_str(), true);
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, m->scale);
|
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, m->scale);
|
||||||
|
|
Loading…
Reference in a new issue