`

Ubuntu之下如何开启壁纸自动切换

阅读更多
  1. 选择一个图片文件夹,将需要用到的壁纸放在该文件下

  2. 在该文件夹下运行如下脚本:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # Name: slidexml.py
    # Author: EthanZ6174
    # Email: <heracles.621@gmail.com>
    # Site: http://www.noslog.com
    # Licence: GPLv3
    # Version: 091127
    
    import glob, os
    import shutil
    import time
    
    
    curdir = os.getcwd()
    os.chdir(curdir)
    currentFilelist = glob.glob('*.*')
    currentImageFiles = glob.glob('*.jpg')
    
    currentTime = time.localtime()
    length = len(currentImageFiles)
    
    for i in currentFilelist:
     if i == 'backgroundslide.xml':
      os.remove(i)
    
    f = file('backgroundslide.xml', 'w')
    
    f.write('<background>\n')
    f.write('\t<starttime>\n')
    f.write('\t\t<year>' + str(currentTime.tm_year) + '</year>\n')
    f.write('\t\t<month>' + str(currentTime.tm_mon) + '</month>\n')
    f.write('\t\t<day>' + str(currentTime.tm_mday) + '</day>\n')
    f.write('\t\t<hour>' + str(currentTime.tm_hour) + '</hour>\n')
    f.write('\t\t<minute>' + str(currentTime.tm_min) + '</minute>\n')
    f.write('\t\t<second>' + str(currentTime.tm_sec) + '</second>\n')
    f.write('\t</starttime>\n')
    f.write('<!--This animation will start at the time it created-->\n')
    
    for i in currentImageFiles:
     length = length - 1
     print length
     #print curdir
     #print currentImageFiles[1]
     f.write('\t<static>\n')
     f.write('\t\t<duration>595.0</duration>\n')
     f.write('\t\t<file>' + curdir + '/' + currentImageFiles[length] +'</file>\n')
     f.write('\t</static>\n')
     f.write('\t<transition>\n')
     f.write('\t\t<duration>5.0</duration>\n')
     f.write('\t\t<from>' + curdir + '/' + currentImageFiles[length] + '</from>\n')
     if length >= 1:
      f.write('\t\t<to>' + curdir + '/' + currentImageFiles[length-1] + '</to>\n')
     if length <1:
      f.write('\t\t<to>' + curdir + '/' + currentImageFiles[len(currentImageFiles)-1] + '</to>\n')
     f.write('\t</transition>\n')
    
    f.write('</background>\n')
    f.close()

     3. 将生成的background.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> 
分享到:
评论

相关推荐

    Ubuntu 20.04 下安装配置 VScode 的 C/C++ 开发环境(图文教程)

    之后Codeblocks倒是安装成功了,但是明明在已经安装了C/C++跟GCC编译包的情况,它仍然显示在该路径下找不到,无论路径是默认自动定位在/usr 还是在/usr/bin 之下仍然出现此情况,同样网上找不到任何解决方法,于是...

    Ubuntu下基于opencv和qt的人脸识别考勤系统.zip

    Qt Core模块是Qt类库的核心,所有其他模块都依赖于此模块,如果使用qmake来构建项目,Qt Core模块则是被自动加入的。 Qt为C++语言增加的特性就是在Qt Core模块里实现的,这些扩展特性由Qt的元对象系统实现,包括...

    c302ca:如何通过取消花式Chromebook上的保修来获得功能全面的ubuntu 20.04可转换笔记本电脑

    华硕C302CA上的Ubuntu 20.04注释 Github和。 华硕Chromebook Flip C302CA在很久以前还是很新的,... 在平板电脑模式下,它甚至会自动调出屏幕上的键盘,并将焦点移至文本输入上。 所有这些都在ubuntu 20.04 LTS上进行

    linux复习题

    1. Ubuntu LINUX安装时自动创建了根用户。( T ) 2. LINUX中的超级用户为root,登陆时不需要口令。( F ) 3. Linux不可以与MS-DOS、OS/2、Windows等其他操作系统共存于同一台机器上。( F ) 4. Linux的特点之一...

    livehaxe:Haxe 和其他工具的自动编译器。 监视项目中的文件并在检测到更改时重新生成输出

    Livehaxe 将在服务器模式下启动 haxe 编译器,扫描包含在 hxml 中的所有-cp并在修改项目中的.hx文件之一时更新您的构建。 少编译 Livehaxe 也可以用来编译 LESS 文件,只需添加: -less src.less dst.css 笔记 ...

    Citrix-XenServer服务器虚拟化测试方案.doc

    服务器虚拟化测试环境示意图 测试内容及结果记录 " "测试项 "测试内容 "测试目标 "测试结果 " " "目 " " " " "1 "虚拟平 "格式化原服务器磁盘之"验证虚拟平台安装过 "通过 " " "台安装 "后安装虚拟化平台需要"程是否...

    lanmp v2.5一键安装包(包括lamp,lnmp,lnamp安装)

    2 增强对ubuntu系统的支持,修正在ubuntu系统下安装可能出现无法添加系统账号的bug 3 nginx升级至1.2.9,apache升级至2.2.24,mysql升级至5.1.69,pureftp升级至1.0.36 4 安装脚本大量调整和优化 5 增加debian系统的支持...

    mirror-recipes

    某些特殊参数会以尽力而为的方式自动检测。 这些包括: ARCH:主持人架构 操作系统:主机操作系统 DIST:主机Linux发行版(仅在Linux上运行时) 请注意,这些参数在其他方面只是普通参数。 因此,要使用它们,脚本...

    基于Qt的多线程流水线异步服务器稳定版

    任意新增服务器节点选择现有服务器集群中的任意一个节点,接入后,通过广播自动与其他服务器节点建立点对点连接。本模块只是提供一个服务器到服务器的通信隧道,不负责具体通信内容的解译。对传输内容的控制,由具体...

    Qt Creator 的安装和hello world 程序+其他程序的编写--不是一般的好

    在Qt Creator 的安装目录的qt 文件下的bin 文件夹下(我安装在了D 盘, 所以路径是D:\Qt\2009.04\qt\bin),可以找到所有的相关.dll 文件。在这里 找到mingwm10.dll 文件,将其复制到C:\WINDOWS\system 文件夹下,...

    VMware Workstation Pro 12.0.0 Build 2985596 - 64bit [ENG] [Serial]

    过期的虚拟机将自动挂起,并且在没有管理员干预的情况下不会重新启动。 vmw-scrnsht-wrkstn-expiringvm-tn.jpg vmw-scrnsht-wrkstn-compatibility-tn.jpg 虚拟机交叉兼容性 Workstation 12 Pro 可提供跨 VMware 产品...

    新版Android开发教程.rar

    • Linux (tested on Linux Ubuntu Dapper Drake) Supported Supported Supported Supported Development Development Development Development Environments Environments Environments Environments Eclipse IDE o...

    Google.Android开发入门与实战

    从技术实现上,讲解了5个Android平台下的完整综合实例及源代码分析,分别是RSS阅读器、基于Google Map的个人GPS、豆瓣网(Web 2.0)客户端、在线音乐播放器、手机信息查看助手。《Android开发入门与实战》注重对实际...

    uboott移植实验手册及技术文档

    1、Ubuntu 7.0.4发行版 2、u-boot-1.3.1 3、FS2410平台 4、交叉编译器 arm-softfloat-linux-gnu-gcc-3.4.5 【实验步骤】 一、建立自己的平台类型 (1)解压文件 #tar jxvf u-boot-1.3.1.tar.bz2 (2)进入 U...

Global site tag (gtag.js) - Google Analytics