diff options
| author | vaxerski <vaxry@vaxry.net> | 2023-01-06 14:32:25 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2023-01-06 14:32:25 +0100 |
| commit | 98ce867104b855824ee218296f91664e1fd60545 (patch) | |
| tree | 5a7e4a11127f28e09ceb3ec6e783b29cf92b27f7 /src/debug/HyprCtl.cpp | |
| parent | 461fab0f27e4913993c6321625b343537aba1bdf (diff) | |
added hyprctl binds
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index e0d4d845..3223ac89 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -461,6 +461,51 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) { return result; } +std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) { + std::string ret = ""; + if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) { + for (auto& kb : g_pKeybindManager->m_lKeybinds) { + ret += "bind"; + if (kb.locked) + ret += "l"; + if (kb.mouse) + ret += "m"; + if (kb.release) + ret += "r"; + if (kb.repeat) + ret += "e"; + + ret += getFormat("\n\tmodmask: %u\n\tsubmap: %s\n\tkey: %s\n\tkeycode: %d\n\tdispatcher: %s\n\targ: %s\n\n", kb.modmask, kb.submap.c_str(), kb.key.c_str(), kb.keycode, + kb.handler.c_str(), kb.arg.c_str()); + } + } else { + // json + ret += "["; + for (auto& kb : g_pKeybindManager->m_lKeybinds) { + ret += getFormat( + R"#( +{ + "locked": %s, + "mouse": %s, + "release": %s, + "repeat": %s, + "modmask": %u, + "submap": "%s", + "key": "%s", + "keycode": %i, + "dispatcher": "%s", + "arg": "%s" +},)#", + kb.locked ? "true" : "false", kb.mouse ? "true" : "false", kb.release ? "true" : "false", kb.repeat ? "true" : "false", kb.modmask, kb.submap.c_str(), + kb.key.c_str(), kb.keycode, kb.handler.c_str(), kb.arg.c_str()); + } + ret.pop_back(); + ret += "]"; + } + + return ret; +} + std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) { if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) { @@ -913,6 +958,8 @@ std::string getReply(std::string request) { return splashRequest(); else if (request == "cursorpos") return cursorPosRequest(format); + else if (request == "binds") + return bindsRequest(format); else if (request.find("switchxkblayout") == 0) return switchXKBLayoutRequest(request); else if (request.find("output") == 0) |
