• 周四. 4 月 23rd, 2026

物嫩软件资讯网

软件资讯来物嫩

ubuntu下实现动态桌面壁纸

admin@wunen

6 月 11, 2025

不知大家在使用ubuntu时有没有注意到,ubuntu下是可以实现多张壁纸动态切换的,好像Win7下也有类似的功能(曾经使用win7一段时间)。我也是最近才注意到这点,下面是在ubuntu10.04下实验的,之前版本的应该也可以。

实现原理是使用一个xml文件来记录可供切换选择的壁纸。下面展示的是10.04中自带的一个样例。

首先说明一下,ubuntu默认的壁纸存放在/usr/share/backgrounds/目录下的,在该目录中还有一个cosmos(意思是“宇宙”)目录,cosmos里面的xml文件就是实现动态桌面壁纸切换功能的了。

jarson@jarson-laptop:/usr/share/backgrounds/cosmos$ ls


background-1.xml

cloud.jpg  earth-horizon.jpg   helix-nebula.jpg  sombrero.jpg

blue-marble-west.jpg  comet.jpg  galaxy-ngc3370.jpg  jupiter.jpg       whirlpool.jpg

jarson@jarson-laptop:/usr/share/backgrounds/cosmos$ cat background-1.xml

<background>

<starttime>

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. –>

“animation”动画的意思


<static>

“static”静态的意思


<duration>1800.0</duration>

duration标签设置持续的时间,以秒为单位。


<file>/usr/share/backgrounds/cosmos/cloud.jpg</file>

file标签指定壁纸存放的路径


</static>

<transition>

“transition”切换的意思


<duration>5.0</duration>


<from>/usr/share/backgrounds/cosmos/cloud.jpg</from> from … to从壁纸A切换到壁纸B。


<to>/usr/share/backgrounds/cosmos/comet.jpg</to>

</transition>

<static>

<duration>1800.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>1800.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>1800.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>1800.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>1800.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>1800.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>1800.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>1800.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>

注意from … to要构成一个循环。

设置动态桌面壁纸有两个好的功能:1、满足自己设置多张壁纸的需要;2、时间提醒,例如我这里设置半小时切换一次,这样每次桌面变换时,我就会知道半个小时又过去了。。。

设置好后的应用方法:右键桌面->更改桌面背景->添加,在弹出对话框的右下方那里选择“全部文件”(默认是“图像”),然后找到你定义好的动态桌面壁纸的xml文件,双击添加就可以了。


发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注