summaryrefslogtreecommitdiff
path: root/src/debug/HyprCtl.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-04-09 13:48:20 +0100
committerGitHub <noreply@github.com>2023-04-09 13:48:20 +0100
commit046ad79d11dbccc90ade48d63aaa340655d999fb (patch)
tree7ffb5ae0d0abd09cba72e42be5a27585531090e4 /src/debug/HyprCtl.cpp
parente4e653ada6fc729efad3f6a0d49cf72b94c43b6c (diff)
GlobalShortcuts protocol impl (#1886)
Implements the `hyprland-global-shortcuts-v1` protocol --------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
Diffstat (limited to 'src/debug/HyprCtl.cpp')
-rw-r--r--src/debug/HyprCtl.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index d4b765e2..bef7c68e 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -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)