From 468c5dde055b004107ecae982d5c60408f550ee1 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Fri, 16 Feb 2024 12:05:03 +0100 Subject: [PATCH] ipc-rules: add wayfire/configuration method Returns information about the current Wayfire instance. --- ipc-scripts/list-methods.py | 5 +++++ plugins/single_plugins/ipc-rules.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ipc-scripts/list-methods.py b/ipc-scripts/list-methods.py index 01454728d..1d7f3d7ad 100644 --- a/ipc-scripts/list-methods.py +++ b/ipc-scripts/list-methods.py @@ -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:") diff --git a/plugins/single_plugins/ipc-rules.cpp b/plugins/single_plugins/ipc-rules.cpp index 5f21a2018..0907ed68a 100644 --- a/plugins/single_plugins/ipc-rules.cpp +++ b/plugins/single_plugins/ipc-rules.cpp @@ -19,6 +19,7 @@ #include "wayfire/window-manager.hpp" #include "wayfire/workarea.hpp" #include "config.h" +#include #include @@ -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); @@ -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"); @@ -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();