aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-01-06 14:32:25 +0100
committervaxerski <[email protected]>2023-01-06 14:32:25 +0100
commit98ce867104b855824ee218296f91664e1fd60545 (patch)
tree5a7e4a11127f28e09ceb3ec6e783b29cf92b27f7
parent461fab0f27e4913993c6321625b343537aba1bdf (diff)
downloadHyprland-98ce867104b855824ee218296f91664e1fd60545.tar.gz
Hyprland-98ce867104b855824ee218296f91664e1fd60545.zip
added hyprctl binds
-rw-r--r--hyprctl/main.cpp5
-rw-r--r--src/debug/HyprCtl.cpp47
-rw-r--r--src/managers/KeybindManager.hpp3
3 files changed, 53 insertions, 2 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index 469baddc..acb7b1b1 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -27,6 +27,7 @@ commands:
activewindow
layers
devices
+ binds
dispatch
keyword
version
@@ -44,7 +45,7 @@ flags:
--batch -> execute a batch of commands, separated by ';'
)#";
-void request(std::string arg, int minArgs = 0) {
+void request(std::string arg, int minArgs = 0) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
@@ -334,6 +335,8 @@ int main(int argc, char** argv) {
request(fullRequest);
else if (fullRequest.contains("/getoption"))
request(fullRequest);
+ else if (fullRequest.contains("/binds"))
+ request(fullRequest);
else if (fullRequest.contains("/cursorpos"))
request(fullRequest);
else if (fullRequest.contains("/switchxkblayout"))
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)
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 9498c529..7794c24c 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -51,8 +51,9 @@ class CKeybindManager {
wl_event_source* m_pActiveKeybindEventSource = nullptr;
+ std::list<SKeybind> m_lKeybinds;
+
private:
- std::list<SKeybind> m_lKeybinds;
std::deque<xkb_keysym_t> m_dPressedKeysyms;
std::deque<int> m_dPressedKeycodes;