gpt4 book ai didi

c - notify_notification_new 不显示图标

转载 作者:太空宇宙 更新时间:2023-11-03 23:32:39 26 4
gpt4 key购买 nike

我完全被难住了。我有这个小东西来简化 MTP 单元在 linux 下的安装,但由于某些原因,我无法让 libnotify 在使用变量时显示我的图标。如果我对完整路径进行硬编码,它可以正常工作,但是当使用变量作为 getcwdgetenv 时,它不会显示。

这是一段代码:

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

我做错了什么?

最佳答案

这看起来不对:

mount = notify_notification_new ("Samsung Galaxy Nexus", "Mounted at ~/Nexus", ("%s%sandroid_on.png", cwd, slash));

第三个参数应该是字符串吗?如果是这样,您需要使用 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);

关于c - notify_notification_new 不显示图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12334781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com