I'm completely stumped. I have this little thing to ease the mounting of MTP units under linux, but for some reason I can't get libnotify to show my icon when using variables. If I hardcode the complete path, it works fine, but when using variables as getcwd
and getenv
, it won't show.
Here is a piece of the code:
char cwd[1024];
char *slash = "/";
{
NotifyNotification *mount;
notify_init ("Galaxy Nexus mounter");
if (getcwd(cwd, sizeof(cwd)) != NULL)
{
mount = notify_notification_new ("Samsung Galaxy Nexus", "Mounted at ~/Nexus", ("%s%sandroid_on.png", cwd, slash));
fprintf(stdout, "Icon used %s%sandroid_on.png\n", cwd, slash);
system("jmtpfs ~/Nexus");
notify_notification_set_timeout (mount, 2000);
notify_notification_show (mount, NULL);
}
}
What am I doing wrong?
This doesn't look right:
mount = notify_notification_new ("Samsung Galaxy Nexus", "Mounted at ~/Nexus", ("%s%sandroid_on.png", cwd, slash));
Is the third parameter supposed to be a string? If so, you need to build it separately with snprintf:
char path[1000];
snprintf (path, sizeof(path), "%s%sandroid_on.png", cwd, slash);
mount = notify_notification_new ("Samsung Galaxy Nexus", "Mounted at ~/Nexus", path);
fprintf(stdout, "Icon used %s\n", path);