mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-16 20:43:48 -07:00
GlobalShortcuts protocol impl (#1886)
Implements the `hyprland-global-shortcuts-v1` protocol --------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
This commit is contained in:
@@ -536,6 +536,29 @@ std::string animationsRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string globalShortcutsRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||
std::string ret = "";
|
||||
const auto SHORTCUTS = g_pProtocolManager->m_pGlobalShortcutsProtocolManager->getAllShortcuts();
|
||||
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
||||
for (auto& sh : SHORTCUTS)
|
||||
ret += getFormat("%s:%s -> %s\n", sh.appid.c_str(), sh.id.c_str(), sh.description.c_str());
|
||||
} else {
|
||||
ret += "[";
|
||||
for (auto& sh : SHORTCUTS) {
|
||||
ret += getFormat(R"#(
|
||||
{
|
||||
"name": "%s",
|
||||
"description": "%s"
|
||||
},)#",
|
||||
escapeJSONStrings(sh.appid + ":" + sh.id).c_str(), escapeJSONStrings(sh.description).c_str());
|
||||
}
|
||||
ret.pop_back();
|
||||
ret += "]\n";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||
std::string ret = "";
|
||||
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
||||
@@ -1228,6 +1251,8 @@ std::string getReply(std::string request) {
|
||||
return cursorPosRequest(format);
|
||||
else if (request == "binds")
|
||||
return bindsRequest(format);
|
||||
else if (request == "globalshortcuts")
|
||||
return globalShortcutsRequest(format);
|
||||
else if (request == "animations")
|
||||
return animationsRequest(format);
|
||||
else if (request.find("plugin") == 0)
|
||||
|
Reference in New Issue
Block a user