为你的 Gnome 2.28 桌面创建自定义过渡背景
在试用新的 Gnome 2.28 桌面时,我惊讶地发现,在默认背景中,有一个“Cosmos”幻灯片,它会定期在你的桌面上过渡显示一些宇宙太空图片。虽然我过去在使用 KDE 时使用过这个功能,但我不知道如何在 Gnome 中创建我自己的幻灯片背景。 通过研究 Cosmos 幻灯片的工作方式,我弄清楚了如何创建我自己的自定义幻灯片背景。继续阅读,了解如何创建你自己的自定义桌面背景。
Gnome 使用一个 XML 文件来包含运行背景幻灯片所需的配置信息。“Cosmos”XML 文件可以在 /usr/share/backgrounds/cosmos/background-1.xml 找到,其中包含 Gnome 需要的所有信息。
以下是它的样子
<background>
<starttime>
<year>2009</year>
<month>08</month>
<day>04</day>
<hour>00</hour>
<minute>00</minute>
<second>00</second>
</starttime>
<!-- This animation will start at midnight. -->
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/cloud.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/cloud.jpg</from>
<to>/usr/share/backgrounds/cosmos/comet.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/comet.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/comet.jpg</from>
<to>/usr/share/backgrounds/cosmos/earth-horizon.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/earth-horizon.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/earth-horizon.jpg</from>
<to>/usr/share/backgrounds/cosmos/blue-marble-west.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/blue-marble-west.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/blue-marble-west.jpg</from>
<to>/usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg</from>
<to>/usr/share/backgrounds/cosmos/helix-nebula.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/helix-nebula.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/helix-nebula.jpg</from>
<to>/usr/share/backgrounds/cosmos/jupiter.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/jupiter.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/jupiter.jpg</from>
<to>/usr/share/backgrounds/cosmos/sombrero.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/sombrero.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/sombrero.jpg</from>
<to>/usr/share/backgrounds/cosmos/whirlpool.jpg</to>
</transition>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/whirlpool.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/whirlpool.jpg</from>
<to>/usr/share/backgrounds/cosmos/cloud.jpg</to>
</transition>
</background>
持续时间以秒为单位列出(<duration> 标签),因此为图像(<static> 标签)指定的 1795.0 秒将是 29 分 55 秒。 在五秒钟的过渡期间(<transition> 标签),先前的图像更改为当前图像。 当此图像显示 1795 秒后,它将过渡到下一个文件。 在“Cosmos”XML 文件中,最后一个文件过渡回列表中的第一个文件。我在我的 XML 模板文件中遵循了这一惯例,你可以使用它来创建你自己的自定义幻灯片列表
<!-- Template created by Ross Larson for linuxjournal.com -->
<background>
<starttime>
<hour>0</hour>
<minute>00</minute>
<second>01</second>
</starttime>
<!-- this creates an arbitrary start time of 12 am -->
<static>
<duration>855.0</duration>
<file>/path/to/wallpaper_number_one.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/path/to/wallpaper_number_one.jpg</from>
<to>/path/to/wallpaper_number_two.jpg</to>
</transition>
<static>
<duration>855.0</duration>
<file>/path/to/wallpaper_number_two.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/path/to/wallpaper_number_two.jpg</from>
<to>/path/to/wallpaper_number_three.jpg</to>
</transition>
<static>
<duration>855.0</duration>
<file>/path/to/wallpaper_number_three.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/path/to/wallpaper_number_three.jpg</from>
<to>/path/to/wallpaper_number_four.jpg</to>
</transition>
<static>
<duration>855.0</duration>
<file>/path/to/wallpaper_number_four.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/path/to/wallpaper_number_four.jpg</from>
<to>/path/to/wallpaper_number_five.jpg</to>
</transition>
<static>
<duration>855.0</duration>
<file>/path/to/wallpaper_number_five.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/path/to/wallpaper_number_five.jpg</from>
<to>/path/to/wallpaper_number_one.jpg</to>
</transition>
</background>
由于我的注意力比创建原始 XML 的 Gnome 开发人员更短,因此我创建了一个默认持续时间为 855.0 + 5.0 秒,即每张图片 15 分钟,包括过渡。 如果你想从你的 XML 中添加或删除额外的图像,只需添加或删除以下内容
<static>
<duration>855.0</duration>
<file>/path/to/wallpaper_you_want_to_add.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/path/to/wallpaper_you_want_to_add.jpg</from>
<to>/path/to/next_wallpaper.jpg</to>
</transition>
解析 XML 文件的经验法则是,你将看到每个图像路径被提及三次
- 一次是从前一个图像过渡到当前图像。
- 一次是指示当前图像的持续时间。
- 一次是从当前图像过渡到下一个图像。
- 将 XML 重命名为你想要的任何名称,只要你保留 .xml 扩展名即可。
- 图像的路径不必指向 /usr/share/backgrounds,但请记住,如果你更改发行版或从一台计算机迁移到另一台计算机,如果图像与你的 XML 文件中指示的路径不同,则 XML 将无法工作。
- 确保在输入有关桌面幻灯片中最后一个图像的信息时,过渡回第一个图像。
- 我建议使用 GVIM 编辑你的 XML 文件,因为我能够广泛使用“查找和替换”功能来更新文件名和持续时间。 如果你像 Kyle Rankin 一样厉害,并且生活在命令行中,你也可以随意使用老式的 vim 文本命令。
要激活你的新背景
右键单击你的桌面以选择“更改桌面背景”
从背景外观首选项窗口中选择“添加”。
选择“所有文件”过滤器以显示你创建的自定义 XML 文件。
选择你的自定义 XML 文件并选择“打开”。 (在这里,我的 XML 文件名为“dualies.xml”)
选择你的新桌面背景幻灯片,并欣赏结果。
这个过程已经在 Ubuntu 9.10 和 Fedora 12 中测试过,但我假设它可以在任何能够运行 Gnome 2.28 的环境中工作
尽情享受吧!