mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 18:05:58 +01:00
Added hyprctl setcursor
This commit is contained in:
parent
f64f94ca56
commit
9b39a0c2e0
3 changed files with 67 additions and 0 deletions
|
@ -34,6 +34,7 @@ commands:
|
||||||
splash
|
splash
|
||||||
hyprpaper
|
hyprpaper
|
||||||
reload
|
reload
|
||||||
|
setcursor
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
-j -> output in JSON
|
-j -> output in JSON
|
||||||
|
@ -183,6 +184,17 @@ void hyprpaperRequest(int argc, char** argv) {
|
||||||
requestHyprpaper(rq);
|
requestHyprpaper(rq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setcursorRequest(int argc, char** argv) {
|
||||||
|
if (argc < 4) {
|
||||||
|
std::cout << "setcursor requires 2 params";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rq = "setcursor " + std::string(argv[2]) + " " + std::string(argv[3]);
|
||||||
|
|
||||||
|
request(rq);
|
||||||
|
}
|
||||||
|
|
||||||
void batchRequest(std::string arg) {
|
void batchRequest(std::string arg) {
|
||||||
std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1);
|
std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1);
|
||||||
|
|
||||||
|
@ -252,6 +264,7 @@ int main(int argc, char** argv) {
|
||||||
else if (fullRequest.contains("/splash")) request(fullRequest);
|
else if (fullRequest.contains("/splash")) request(fullRequest);
|
||||||
else if (fullRequest.contains("/devices")) request(fullRequest);
|
else if (fullRequest.contains("/devices")) request(fullRequest);
|
||||||
else if (fullRequest.contains("/reload")) request(fullRequest);
|
else if (fullRequest.contains("/reload")) request(fullRequest);
|
||||||
|
else if (fullRequest.contains("/setcursor")) setcursorRequest(argc, argv);
|
||||||
else if (fullRequest.contains("/dispatch")) dispatchRequest(argc, argv);
|
else if (fullRequest.contains("/dispatch")) dispatchRequest(argc, argv);
|
||||||
else if (fullRequest.contains("/keyword")) keywordRequest(argc, argv);
|
else if (fullRequest.contains("/keyword")) keywordRequest(argc, argv);
|
||||||
else if (fullRequest.contains("/hyprpaper")) hyprpaperRequest(argc, argv);
|
else if (fullRequest.contains("/hyprpaper")) hyprpaperRequest(argc, argv);
|
||||||
|
|
|
@ -522,6 +522,56 @@ std::string dispatchBatch(std::string request) {
|
||||||
return reply;
|
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) {
|
std::string getReply(std::string request) {
|
||||||
auto format = HyprCtl::FORMAT_NORMAL;
|
auto format = HyprCtl::FORMAT_NORMAL;
|
||||||
|
|
||||||
|
@ -567,6 +617,8 @@ std::string getReply(std::string request) {
|
||||||
return dispatchRequest(request);
|
return dispatchRequest(request);
|
||||||
else if (request.find("keyword") == 0)
|
else if (request.find("keyword") == 0)
|
||||||
return dispatchKeyword(request);
|
return dispatchKeyword(request);
|
||||||
|
else if (request.find("setcursor") == 0)
|
||||||
|
return dispatchSetCursor(request);
|
||||||
else if (request.find("[[BATCH]]") == 0)
|
else if (request.find("[[BATCH]]") == 0)
|
||||||
return dispatchBatch(request);
|
return dispatchBatch(request);
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,8 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
|
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
|
||||||
g_pCompositor->m_pLastMonitor = this;
|
g_pCompositor->m_pLastMonitor = this;
|
||||||
|
|
||||||
|
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
|
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue