mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-09-11 13:25:42 +03:00
hyprctl: add notify
This commit is contained in:
parent
dd4270eadf
commit
22721a37d5
@ -42,6 +42,7 @@ commands:
|
||||
seterror
|
||||
setprop
|
||||
plugin
|
||||
notify
|
||||
|
||||
flags:
|
||||
-j -> output in JSON
|
||||
@ -352,6 +353,8 @@ int main(int argc, char** argv) {
|
||||
request(fullRequest, 3);
|
||||
else if (fullRequest.contains("/plugin"))
|
||||
request(fullRequest, 1);
|
||||
else if (fullRequest.contains("/notify"))
|
||||
request(fullRequest, 2);
|
||||
else if (fullRequest.contains("/output"))
|
||||
exitStatus = outputRequest(argc, argv);
|
||||
else if (fullRequest.contains("/setcursor"))
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user