notify: Add custom fontsize support for notifications (#4981)

* Add custom fontsize support for notifications

* Remove debug stuff

* Use original default font size

* Handle fontsize as keyword arg

* Use CVarList::join instead of for loop

* Use size_t for msgidx
This commit is contained in:
ItsDrike 2024-03-06 22:20:26 +01:00 committed by GitHub
parent 8e2a62e53b
commit 067df84388
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 26 deletions

View file

@ -1455,17 +1455,29 @@ std::string dispatchNotify(eHyprCtlOutputFormat format, std::string request) {
time = std::stoi(TIME);
} catch (std::exception& e) { return "invalid arg 2"; }
CColor color = configStringToInt(vars[3]);
CColor color = configStringToInt(vars[3]);
std::string message = "";
size_t msgidx = 4;
float fontsize = 13.f;
if (vars[msgidx].length() > 9 && vars[msgidx].compare(0, 10, "fontsize:")) {
const auto FONTSIZE = vars[msgidx].substr(9);
for (size_t i = 4; i < vars.size(); ++i) {
message += vars[i] + " ";
if (!isNumber(FONTSIZE, true))
return "invalid fontsize kwarg";
try {
fontsize = std::stoi(FONTSIZE);
} catch (std::exception& e) { return "invalid fontsize karg"; }
++msgidx;
}
message.pop_back();
if (vars.size() <= msgidx)
return "not enough args";
g_pHyprNotificationOverlay->addNotification(message, color, time, (eIcons)icon);
const auto MESSAGE = vars.join(" ", msgidx);
g_pHyprNotificationOverlay->addNotification(MESSAGE, color, time, (eIcons)icon, fontsize);
return "ok";
}