mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 14:25:59 +01:00
hyprctl: add notify
This commit is contained in:
parent
dd4270eadf
commit
22721a37d5
2 changed files with 46 additions and 0 deletions
|
@ -42,6 +42,7 @@ commands:
|
||||||
seterror
|
seterror
|
||||||
setprop
|
setprop
|
||||||
plugin
|
plugin
|
||||||
|
notify
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
-j -> output in JSON
|
-j -> output in JSON
|
||||||
|
@ -352,6 +353,8 @@ int main(int argc, char** argv) {
|
||||||
request(fullRequest, 3);
|
request(fullRequest, 3);
|
||||||
else if (fullRequest.contains("/plugin"))
|
else if (fullRequest.contains("/plugin"))
|
||||||
request(fullRequest, 1);
|
request(fullRequest, 1);
|
||||||
|
else if (fullRequest.contains("/notify"))
|
||||||
|
request(fullRequest, 2);
|
||||||
else if (fullRequest.contains("/output"))
|
else if (fullRequest.contains("/output"))
|
||||||
exitStatus = outputRequest(argc, argv);
|
exitStatus = outputRequest(argc, argv);
|
||||||
else if (fullRequest.contains("/setcursor"))
|
else if (fullRequest.contains("/setcursor"))
|
||||||
|
|
|
@ -1137,6 +1137,47 @@ std::string dispatchPlugin(std::string request) {
|
||||||
return "ok";
|
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) {
|
std::string getReply(std::string request) {
|
||||||
auto format = HyprCtl::FORMAT_NORMAL;
|
auto format = HyprCtl::FORMAT_NORMAL;
|
||||||
|
|
||||||
|
@ -1186,6 +1227,8 @@ std::string getReply(std::string request) {
|
||||||
return animationsRequest(format);
|
return animationsRequest(format);
|
||||||
else if (request.find("plugin") == 0)
|
else if (request.find("plugin") == 0)
|
||||||
return dispatchPlugin(request);
|
return dispatchPlugin(request);
|
||||||
|
else if (request.find("notify") == 0)
|
||||||
|
return dispatchNotify(request);
|
||||||
else if (request.find("setprop") == 0)
|
else if (request.find("setprop") == 0)
|
||||||
return dispatchSetProp(request);
|
return dispatchSetProp(request);
|
||||||
else if (request.find("seterror") == 0)
|
else if (request.find("seterror") == 0)
|
||||||
|
|
Loading…
Reference in a new issue