summaryrefslogtreecommitdiff
path: root/src/plugins/PluginAPI.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-26 15:16:36 +0100
committerGitHub <noreply@github.com>2026-04-26 15:16:36 +0100
commit5ba33f846129f3e6c0505b19f94634b24505e828 (patch)
treeaaacabe678006040c342935481a86607c66607fd /src/plugins/PluginAPI.hpp
parent329b2b356dd92ac07f4e2aa69cbce82ee9ba9d19 (diff)
config/lua: init lua config manager, use lua if available (#13817)
Adds a new lua config manager, which will automatically be used if there is a lua config present.
Diffstat (limited to 'src/plugins/PluginAPI.hpp')
-rw-r--r--src/plugins/PluginAPI.hpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp
index 77bb9926..5321c8db 100644
--- a/src/plugins/PluginAPI.hpp
+++ b/src/plugins/PluginAPI.hpp
@@ -25,6 +25,7 @@ Feel like the API is missing something you'd like to use in your plugin? Open an
#include "../SharedDefs.hpp"
#include "../defines.hpp"
#include "../version.h"
+#include "../config/values/types/IValue.hpp"
#include <any>
#include <functional>
@@ -71,6 +72,9 @@ class IHyprLayout;
class IHyprWindowDecoration;
struct SConfigValue;
class Hypr_dummyClass {};
+extern "C" {
+struct lua_State;
+}
namespace Layout {
class ITiledAlgorithm;
@@ -78,6 +82,7 @@ namespace Layout {
};
using HOOK_CALLBACK_FN = Hypr_dummyClass;
+using PLUGIN_LUA_FN = int (*)(lua_State* L);
/*
These methods are for the plugin to implement
@@ -129,16 +134,20 @@ namespace HyprlandAPI {
After you have registered ALL of your config values, you may call `getConfigValue`
returns: true on success, false on fail
+
+ deprecated: please use V2
*/
- APICALL bool addConfigValue(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value);
+ APICALL [[deprecated]] bool addConfigValue(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value);
/*
Add a config keyword.
This method may only be called in "pluginInit"
returns: true on success, false on fail
+
+ deprecated: please use V2
*/
- APICALL bool addConfigKeyword(HANDLE handle, const std::string& name, Hyprlang::PCONFIGHANDLERFUNC fn, Hyprlang::SHandlerOptions opts);
+ APICALL [[deprecated]] bool addConfigKeyword(HANDLE handle, const std::string& name, Hyprlang::PCONFIGHANDLERFUNC fn, Hyprlang::SHandlerOptions opts);
/*
Get a config value.
@@ -147,8 +156,10 @@ namespace HyprlandAPI {
returns: a pointer to the config value struct, which is guaranteed to be valid for the life of this plugin, unless another `addConfigValue` is called afterwards.
nullptr on error.
+
+ Deprecated: please use V2
*/
- APICALL Hyprlang::CConfigValue* getConfigValue(HANDLE handle, const std::string& name);
+ APICALL [[deprecated]] Hyprlang::CConfigValue* getConfigValue(HANDLE handle, const std::string& name);
/*
Deprecated: doesn't do anything anymore, use Event::bus()
@@ -325,6 +336,32 @@ namespace HyprlandAPI {
returns: true on success. False otherwise.
*/
APICALL bool unregisterHyprCtlCommand(HANDLE handle, SP<SHyprCtlCommand> cmd);
+
+ /*
+ Add a new config value. Keep the pointer, you can use it for retrieving the value.
+
+ Please note this value name must start with plugin:, e.g. plugin:my_plugin:value
+
+ returns: true on success. False otherwise.
+ */
+ APICALL bool addConfigValueV2(HANDLE handle, SP<Config::Values::IValue> value);
+
+ /*
+ Register a plugin-owned Lua C callback under hl.plugin.<namespace>.<name>.
+
+ Callbacks are removed automatically on plugin unload.
+
+ returns: true on success. False otherwise.
+ */
+ APICALL bool addLuaFunction(HANDLE handle, const std::string& namespace_, const std::string& name, PLUGIN_LUA_FN fn);
+
+ /*
+ Unregister a plugin-owned Lua C callback from hl.plugin.<namespace>.<name>.
+
+ returns: true on success. False otherwise.
+ */
+ APICALL bool removeLuaFunction(HANDLE handle, const std::string& namespace_, const std::string& name);
+
};
// NOLINTBEGIN