aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-20 16:00:54 +0000
committervaxerski <[email protected]>2023-03-20 16:00:54 +0000
commit22721a37d5f4b9fadbc34cfe58f364e36c2c6712 (patch)
tree8f6956a1545af674547f14eb8d91e6b83603586a /src
parentdd4270eadf8a62f4e8f417ff8a78f445745c6096 (diff)
downloadHyprland-22721a37d5f4b9fadbc34cfe58f364e36c2c6712.tar.gz
Hyprland-22721a37d5f4b9fadbc34cfe58f364e36c2c6712.zip
hyprctl: add notify
Diffstat (limited to 'src')
-rw-r--r--src/debug/HyprCtl.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 74dd7a15..c9b8a25d 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -1137,6 +1137,47 @@ std::string dispatchPlugin(std::string request) {
return "ok";
}
+std::string dispatchNotify(std::string request) {
+ CVarList vars(request, 0, ' ');
+
+ if (vars.size() < 5)
+ return "not enough args";
+
+ const auto ICON = vars[1];
+
+ if (!isNumber(ICON))
+ return "invalid arg 1";
+
+ int icon = -1;
+ try {
+ icon = std::stoi(ICON);
+ } catch (std::exception& e) { return "invalid arg 1"; }
+
+ if (icon == -1 || icon > ICON_NONE) {
+ icon = ICON_NONE;
+ }
+
+ const auto TIME = vars[2];
+ int time = 0;
+ try {
+ time = std::stoi(TIME);
+ } catch (std::exception& e) { return "invalid arg 2"; }
+
+ CColor color = configStringToInt(vars[3]);
+
+ std::string message = "";
+
+ for (size_t i = 4; i < vars.size(); ++i) {
+ message += vars[i] + " ";
+ }
+
+ message.pop_back();
+
+ g_pHyprNotificationOverlay->addNotification(message, color, time, (eIcons)icon);
+
+ return "ok";
+}
+
std::string getReply(std::string request) {
auto format = HyprCtl::FORMAT_NORMAL;
@@ -1186,6 +1227,8 @@ std::string getReply(std::string request) {
return animationsRequest(format);
else if (request.find("plugin") == 0)
return dispatchPlugin(request);
+ else if (request.find("notify") == 0)
+ return dispatchNotify(request);
else if (request.find("setprop") == 0)
return dispatchSetProp(request);
else if (request.find("seterror") == 0)