我需要在单击时运行功能的 libnotify 通知的底部添加按钮。我可以使按钮出现,但单击时它们不会运行这些功能。它根本没有给出任何错误信息。
该程序被调用./notifications "Title" "Body" "pathtoicon"
代码:
#include <libnotify/notify.h>
#include <iostream>
void callback_mute(NotifyNotification* n, char* action, gpointer user_data) {
std::cout << "Muting Program" << std::endl;
system("pkexec kernel-notify -am");
}
int main(int argc, char * argv[] ) {
GError *error = NULL;
notify_init("Basics");
NotifyNotification* n = notify_notification_new (argv[1],
argv[2],
argv[3]);
notify_notification_add_action (n,
"action_click",
"Mute",
NOTIFY_ACTION_CALLBACK(callback_mute),
NULL,
NULL);
notify_notification_set_timeout(n, 10000);
if (!notify_notification_show(n, 0)) {
std::cerr << "Notification failed" << std::endl;
return 1;
}
return 0;
}
任何帮助将不胜感激,谢谢!