mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 12:46:00 +01:00
added hyprctl binds
This commit is contained in:
parent
461fab0f27
commit
98ce867104
3 changed files with 53 additions and 2 deletions
|
@ -27,6 +27,7 @@ commands:
|
||||||
activewindow
|
activewindow
|
||||||
layers
|
layers
|
||||||
devices
|
devices
|
||||||
|
binds
|
||||||
dispatch
|
dispatch
|
||||||
keyword
|
keyword
|
||||||
version
|
version
|
||||||
|
@ -44,7 +45,7 @@ flags:
|
||||||
--batch -> execute a batch of commands, separated by ';'
|
--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 SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
|
const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
|
||||||
|
@ -334,6 +335,8 @@ int main(int argc, char** argv) {
|
||||||
request(fullRequest);
|
request(fullRequest);
|
||||||
else if (fullRequest.contains("/getoption"))
|
else if (fullRequest.contains("/getoption"))
|
||||||
request(fullRequest);
|
request(fullRequest);
|
||||||
|
else if (fullRequest.contains("/binds"))
|
||||||
|
request(fullRequest);
|
||||||
else if (fullRequest.contains("/cursorpos"))
|
else if (fullRequest.contains("/cursorpos"))
|
||||||
request(fullRequest);
|
request(fullRequest);
|
||||||
else if (fullRequest.contains("/switchxkblayout"))
|
else if (fullRequest.contains("/switchxkblayout"))
|
||||||
|
|
|
@ -461,6 +461,51 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
return result;
|
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) {
|
std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
||||||
|
@ -913,6 +958,8 @@ std::string getReply(std::string request) {
|
||||||
return splashRequest();
|
return splashRequest();
|
||||||
else if (request == "cursorpos")
|
else if (request == "cursorpos")
|
||||||
return cursorPosRequest(format);
|
return cursorPosRequest(format);
|
||||||
|
else if (request == "binds")
|
||||||
|
return bindsRequest(format);
|
||||||
else if (request.find("switchxkblayout") == 0)
|
else if (request.find("switchxkblayout") == 0)
|
||||||
return switchXKBLayoutRequest(request);
|
return switchXKBLayoutRequest(request);
|
||||||
else if (request.find("output") == 0)
|
else if (request.find("output") == 0)
|
||||||
|
|
|
@ -51,8 +51,9 @@ class CKeybindManager {
|
||||||
|
|
||||||
wl_event_source* m_pActiveKeybindEventSource = nullptr;
|
wl_event_source* m_pActiveKeybindEventSource = nullptr;
|
||||||
|
|
||||||
|
std::list<SKeybind> m_lKeybinds;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<SKeybind> m_lKeybinds;
|
|
||||||
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
||||||
std::deque<int> m_dPressedKeycodes;
|
std::deque<int> m_dPressedKeycodes;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue