在 Linux 上以编程方式更改壁纸
如何在 C/C++ 程序中更改 Linux 桌面(使用 GNOME)上的壁纸? 有系统API可以实现吗?
How would I change the wallpaper on a Linux desktop (using GNOME) within a C/C++ program? Is there a system API to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 gconf 库来完成此操作。 以下示例是一个更改背景的完整程序:
上面的源代码基于 gthumb 项目。 可以使用以下字符串对其进行编译:
You could use gconf library to do it. The following sample is a complete program to change background:
The source above is based on gthumb project. It could be compiled with the following string:
虽然问题是针对 gnome 的,但还有一种处理壁纸的方法,该方法不依赖于更高层的工具包。 您应该能够通过研究 xsetroot.c,其中最有趣的部分我复制粘贴在这里:
Though the question was gnome-specific, there's also a way to deal with the wallpaper that is not depepndant on the higher layer toolkits. You should be able to deal with the root window (which the wallpaper is, in fact) by studying the source of xsetroot.c, the most interesting part of which I copypaste here:
如果不出意外,您可能可以使用
system()
来调用此处建议的命令行之一:http://www.linuxquestions.org/questions/linux-general-1/change-background-via-command-line-350936 /
If nothing else, you could probably use
system()
to invoke one of the command lines suggested here:http://www.linuxquestions.org/questions/linux-general-1/change-background-via-command-line-350936/