mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 12:46:00 +01:00
added hyprctl getoption
This commit is contained in:
parent
f85c765634
commit
9102471610
4 changed files with 55 additions and 0 deletions
|
@ -35,6 +35,7 @@ commands:
|
||||||
hyprpaper
|
hyprpaper
|
||||||
reload
|
reload
|
||||||
setcursor
|
setcursor
|
||||||
|
getoption
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
-j -> output in JSON
|
-j -> output in JSON
|
||||||
|
@ -264,6 +265,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("/getoption")) request(fullRequest);
|
||||||
else if (fullRequest.contains("/setcursor")) setcursorRequest(argc, argv);
|
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);
|
||||||
|
|
|
@ -1331,6 +1331,15 @@ SConfigValue* CConfigManager::getConfigValuePtr(std::string val) {
|
||||||
return &configValues[val];
|
return &configValues[val];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SConfigValue* CConfigManager::getConfigValuePtrSafe(std::string val) {
|
||||||
|
const auto IT = configValues.find(val);
|
||||||
|
|
||||||
|
if (IT == configValues.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return &(IT->second);
|
||||||
|
}
|
||||||
|
|
||||||
bool CConfigManager::deviceConfigExists(const std::string& dev) {
|
bool CConfigManager::deviceConfigExists(const std::string& dev) {
|
||||||
const auto it = deviceConfigs.find(dev);
|
const auto it = deviceConfigs.find(dev);
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
bool shouldBlurLS(const std::string&);
|
bool shouldBlurLS(const std::string&);
|
||||||
|
|
||||||
SConfigValue* getConfigValuePtr(std::string);
|
SConfigValue* getConfigValuePtr(std::string);
|
||||||
|
SConfigValue* getConfigValuePtrSafe(std::string);
|
||||||
|
|
||||||
SMonitorRule getMonitorRuleFor(std::string);
|
SMonitorRule getMonitorRuleFor(std::string);
|
||||||
|
|
||||||
|
|
|
@ -572,6 +572,47 @@ std::string dispatchSetCursor(std::string request) {
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
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 PCFGOPT = g_pConfigManager->getConfigValuePtrSafe(curitem);
|
||||||
|
|
||||||
|
if (!PCFGOPT)
|
||||||
|
return "no such option";
|
||||||
|
|
||||||
|
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL)
|
||||||
|
return getFormat("option %s\n\tint: %i\n\tfloat: %f\n\tstr: \"%s\"", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str());
|
||||||
|
else {
|
||||||
|
return getFormat(
|
||||||
|
R"#(
|
||||||
|
{
|
||||||
|
"option": "%s",
|
||||||
|
"int": %i,
|
||||||
|
"float": %f,
|
||||||
|
"str": "%s"
|
||||||
|
}
|
||||||
|
)#", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string getReply(std::string request) {
|
std::string getReply(std::string request) {
|
||||||
auto format = HyprCtl::FORMAT_NORMAL;
|
auto format = HyprCtl::FORMAT_NORMAL;
|
||||||
|
|
||||||
|
@ -619,6 +660,8 @@ std::string getReply(std::string request) {
|
||||||
return dispatchKeyword(request);
|
return dispatchKeyword(request);
|
||||||
else if (request.find("setcursor") == 0)
|
else if (request.find("setcursor") == 0)
|
||||||
return dispatchSetCursor(request);
|
return dispatchSetCursor(request);
|
||||||
|
else if (request.find("getoption") == 0)
|
||||||
|
return dispatchGetOption(request, format);
|
||||||
else if (request.find("[[BATCH]]") == 0)
|
else if (request.find("[[BATCH]]") == 0)
|
||||||
return dispatchBatch(request);
|
return dispatchBatch(request);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue