实现原理是使用一个xml文件来记录可供切换选择的壁纸。下面展示的是10.04中自带的一个样例。
首先说明一下,ubuntu默认的壁纸存放在/usr/share/backgrounds/目录下的,在该目录中还有一个cosmos(意思是“宇宙”)目录,cosmos里面的xml文件就是实现动态桌面壁纸切换功能的了。
本脚本就是对给定图片文件夹快速生成相应 xml配置文件。
现在关键是生成相应的xml 配置文件了,里面的类容比较繁杂,手动更新太麻烦了,所以想到以脚本实现。
1. perl 写成的源代码如下:
首先说明一下,ubuntu默认的壁纸存放在/usr/share/backgrounds/目录下的,在该目录中还有一个cosmos(意思是“宇宙”)目录,cosmos里面的xml文件就是实现动态桌面壁纸切换功能的了。
本脚本就是对给定图片文件夹快速生成相应 xml配置文件。
现在关键是生成相应的xml 配置文件了,里面的类容比较繁杂,手动更新太麻烦了,所以想到以脚本实现。
1. perl 写成的源代码如下:
#!/usr/bin/perl
#==============================================================================#
#-------------------------------help-info-start--------------------------------#
=head1 Name
getBackgroundXML.pl --> generate the background.xml file to change Ubuntu background picture dynamiclly
=head1 Usage
perl getBackgroundXML.pl [<options>] [-d PicDir='.'] [-t TimeToLast=1795.0] [-i Interval=5.0] [-o Background.xml=STDOUT]
-help print this help to screen
-a flag ,if set ,write all pictures to one xml file
-d directory contains the jpgs, defalt : '.'
-t time to change background picture, unit : seconds, default : 1795.0
-i interval time spend to change the two pictures, default : 5.0
-o write result to a file , default : STDOUT
=head1 Example
perl getBackgroundXML.pl -d Windows7 -t 25 -i 5 -o Windows7.xml
perl getBackgroundXML.pl --
=head1 Version
Verion : 2.0
Created : 08/18/2010 03:34:52 PM
Updated : 08/18