Skip to content

Commit

Permalink
ipc-rules: add wayfire/configuration method
Browse files Browse the repository at this point in the history
Returns information about the current Wayfire instance.
  • Loading branch information
ammen99 committed Feb 16, 2024
1 parent ce73843 commit 468c5dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ipc-scripts/list-methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
addr = os.getenv('WAYFIRE_SOCKET')
sock = ws.WayfireSocket(addr)

query = ws.get_msg_template('wayfire/configuration')
response = sock.send_json(query)
print("Wayfire version:")
print(json.dumps(response, indent=4))

query = ws.get_msg_template('list-methods')
response = sock.send_json(query)
print("Supported methods:")
Expand Down
17 changes: 17 additions & 0 deletions plugins/single_plugins/ipc-rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "wayfire/window-manager.hpp"
#include "wayfire/workarea.hpp"
#include "config.h"
#include <wayfire/debug.hpp>
#include <wayfire/nonstd/wlroots-full.hpp>


Expand Down Expand Up @@ -128,6 +129,7 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker
public:
void init() override
{
method_repository->register_method("wayfire/configuration", get_wayfire_configuration_info);
method_repository->register_method("input/list-devices", list_input_devices);
method_repository->register_method("input/configure-device", configure_input_device);
method_repository->register_method("window-rules/events/watch", on_client_watch);
Expand All @@ -149,6 +151,7 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker

void fini() override
{
method_repository->unregister_method("wayfire/configuration");
method_repository->unregister_method("input/list-devices");
method_repository->unregister_method("input/configure-device");
method_repository->unregister_method("window-rules/events/watch");
Expand All @@ -174,6 +177,20 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker
// no-op
}

wf::ipc::method_callback get_wayfire_configuration_info = [=] (nlohmann::json)
{
nlohmann::json response;

response["api-version"] = WAYFIRE_API_ABI_VERSION;
response["plugin-path"] = PLUGIN_PATH;
response["plugin-xml-dir"] = PLUGIN_XML_DIR;
response["xwayland-support"] = WF_HAS_XWAYLAND;

response["build-commit"] = wf::version::git_commit;
response["build-branch"] = wf::version::git_branch;
return response;
};

wf::ipc::method_callback list_views = [=] (nlohmann::json)
{
auto response = nlohmann::json::array();
Expand Down

0 comments on commit 468c5dd

Please sign in to comment.