Skip to content

Commit

Permalink
ipc: add a method to list all available methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Feb 8, 2024
1 parent 50de0a1 commit d5cd65e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ipc-scripts/list-methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import wayfire_socket as ws
import os
import json

addr = os.getenv('WAYFIRE_SOCKET')
sock = ws.WayfireSocket(addr)

query = ws.get_msg_template('list-methods')
response = sock.send_json(query)
print("Supported methods:")
print(json.dumps(response['methods'], indent=4))
15 changes: 15 additions & 0 deletions plugins/ipc/ipc-method-repository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ class method_repository_t
};
}

method_repository_t()
{
register_method("list-methods", [this] (auto)
{
nlohmann::json response;
response["methods"] = nlohmann::json::array();
for (auto& [method, _] : methods)
{
response["methods"].push_back(method);
}

return response;
});
}

private:
std::map<std::string, method_callback> methods;
};
Expand Down

0 comments on commit d5cd65e

Please sign in to comment.