mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-12-01 18:55:02 +03:00
added hyprctl binds
This commit is contained in:
parent
461fab0f27
commit
98ce867104
@ -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"))
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user