How to use notify-send with C++?
Okay so this is how I did it. First install libnotify-dev
:
sudo apt-get install libnotify-dev
this will install the lib on your system and put the headers of the lib to /usr/include/libnotify/
You can take a look at the header files to find out how to use the lib. I did the following:
#include <libnotify/notify.h>
#include <iostream>
int main(int argc, char * argv[] )
{
notify_init("Sample");
NotifyNotification* n = notify_notification_new ("Hello world",
"some message text... bla bla",
0);
notify_notification_set_timeout(n, 10000); // 10 seconds
if (!notify_notification_show(n, 0))
{
std::cerr << "show has failed" << std::endl;
return -1;
}
return 0;
}
In order to build this type:
g++ hello_world.cc -o hello_world `pkg-config --cflags --libs libnotify`
And here is the result: