summaryrefslogtreecommitdiff
path: root/src/debug/HyprCtl.cpp
diff options
context:
space:
mode:
authorItsDrike <itsdrike@protonmail.com>2024-03-06 22:20:26 +0100
committerGitHub <noreply@github.com>2024-03-06 21:20:26 +0000
commit067df84388be41b7b2352918060c2e9d88717740 (patch)
treeb955f35db619629ba6fe842834c65db987024124 /src/debug/HyprCtl.cpp
parent8e2a62e53bf51e8b4ae719d0e46797b0a26eeb22 (diff)
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
Diffstat (limited to 'src/debug/HyprCtl.cpp')
-rw-r--r--src/debug/HyprCtl.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 10302b08..332e3969 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -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";
+
+ const auto MESSAGE = vars.join(" ", msgidx);
- g_pHyprNotificationOverlay->addNotification(message, color, time, (eIcons)icon);
+ g_pHyprNotificationOverlay->addNotification(MESSAGE, color, time, (eIcons)icon, fontsize);
return "ok";
}