summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/PluginAPI.cpp48
-rw-r--r--src/plugins/PluginAPI.hpp16
2 files changed, 64 insertions, 0 deletions
diff --git a/src/plugins/PluginAPI.cpp b/src/plugins/PluginAPI.cpp
index 8c816546..c878516b 100644
--- a/src/plugins/PluginAPI.cpp
+++ b/src/plugins/PluginAPI.cpp
@@ -193,3 +193,51 @@ APICALL bool HyprlandAPI::removeDispatcher(HANDLE handle, const std::string& nam
return true;
}
+
+APICALL bool addNotificationV2(HANDLE handle, const std::unordered_map<std::string, std::any>& data) {
+ auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
+
+ if (!PLUGIN)
+ return false;
+
+ try {
+ auto iterator = data.find("text");
+ if (iterator == data.end())
+ return false;
+
+ // mandatory
+ std::string text;
+ try {
+ text = std::any_cast<std::string>(iterator->second);
+ } catch (std::exception& e) {
+ // attempt const char*
+ text = std::any_cast<const char*>(iterator->second);
+ }
+
+ iterator = data.find("time");
+ if (iterator == data.end())
+ return false;
+
+ const auto TIME = std::any_cast<uint64_t>(iterator->second);
+
+ iterator = data.find("color");
+ if (iterator == data.end())
+ return false;
+
+ const auto COLOR = std::any_cast<CColor>(iterator->second);
+
+ // optional
+ eIcons icon = ICON_NONE;
+ iterator = data.find("icon");
+ if (iterator != data.end())
+ icon = std::any_cast<eIcons>(iterator->second);
+
+ g_pHyprNotificationOverlay->addNotification(text, COLOR, TIME, icon);
+
+ } catch (std::exception& e) {
+ // bad any_cast most likely, plugin error
+ return false;
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp
index 756a5631..80744bc3 100644
--- a/src/plugins/PluginAPI.hpp
+++ b/src/plugins/PluginAPI.hpp
@@ -19,6 +19,7 @@ See examples/examplePlugin for an example plugin
#include "../helpers/Color.hpp"
#include "HookSystem.hpp"
+#include "../SharedDefs.hpp"
#include <any>
#include <functional>
@@ -214,4 +215,19 @@ namespace HyprlandAPI {
returns: true on success. False otherwise.
*/
APICALL bool removeDispatcher(HANDLE handle, const std::string& name);
+
+ /*
+ Adds a notification.
+
+ data has to contain:
+ - text: std::string or const char*
+ - time: uint64_t
+ - color: CColor
+
+ data may contain:
+ - icon: eIcons
+
+ returns: true on success. False otherwise.
+ */
+ APICALL bool addNotificationV2(HANDLE handle, const std::unordered_map<std::string, std::any>& data);
}; \ No newline at end of file