Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

notify-send in C code

Tags:

c

popup

How can I call notify-send from C code with a message stored in my string ?

#include <stdlib.h>

int main(int argc, char *argv[]) 
{
   system("mount something somewhere");
   system("notify-send message");
   return 0;
}
like image 222
NonSense Avatar asked Sep 27 '26 14:09

NonSense


1 Answers

Just send the string as a parameter to system().

For example:

#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]) 
{
    char command[100], msg[100];

    strcpy(command,"notify-send ");
    strcpy(msg,"\"Hello World\"");
    strcat(command,msg);

    system(command);
    return 0; 
}
like image 186
ani627 Avatar answered Sep 29 '26 03:09

ani627



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!