notifs: Implement notification dimissing (#4790)

This commit is contained in:
ItsDrike
2024-03-02 19:12:31 +01:00
committed by GitHub
parent 8811f4b69a
commit be89d6faa9
4 changed files with 37 additions and 0 deletions

View File

@@ -1430,6 +1430,26 @@ std::string dispatchNotify(eHyprCtlOutputFormat format, std::string request) {
return "ok";
}
std::string dispatchDismissNotify(eHyprCtlOutputFormat format, std::string request) {
CVarList vars(request, 0, ' ');
int amount = -1;
if (vars.size() > 1) {
const auto AMOUNT = vars[1];
if (!isNumber(AMOUNT))
return "invalid arg 1";
try {
amount = std::stoi(AMOUNT);
} catch (std::exception& e) { return "invalid arg 1"; }
}
g_pHyprNotificationOverlay->dismissNotifications(amount);
return "ok";
}
CHyprCtl::CHyprCtl() {
registerCommand(SHyprCtlCommand{"workspaces", true, workspacesRequest});
registerCommand(SHyprCtlCommand{"workspacerules", true, workspaceRulesRequest});
@@ -1453,6 +1473,7 @@ CHyprCtl::CHyprCtl() {
registerCommand(SHyprCtlCommand{"reload", false, reloadRequest});
registerCommand(SHyprCtlCommand{"plugin", false, dispatchPlugin});
registerCommand(SHyprCtlCommand{"notify", false, dispatchNotify});
registerCommand(SHyprCtlCommand{"dismissnotify", false, dispatchDismissNotify});
registerCommand(SHyprCtlCommand{"setprop", false, dispatchSetProp});
registerCommand(SHyprCtlCommand{"seterror", false, dispatchSeterror});
registerCommand(SHyprCtlCommand{"switchxkblayout", false, switchXKBLayoutRequest});