notify-send in C code

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;
}
0

2 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;
}
#include <stdio.h>
int main(void)
{ system("notify-send Test \"Hello World\""); return 0;
}
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like