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

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

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

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # Name: slidexml.py
    # Author: EthanZ6174
    # Email: 
    # 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('\n')
    f.write('\t\n')
    f.write('\t\t' + str(currentTime.tm_year) + '\n')
    f.write('\t\t' + str(currentTime.tm_mon) + '\n')
    f.write('\t\t' + str(currentTime.tm_mday) + '\n')
    f.write('\t\t' + str(currentTime.tm_hour) + '\n')
    f.write('\t\t' + str(currentTime.tm_min) + '\n')
    f.write('\t\t' + str(currentTime.tm_sec) + '\n')
    f.write('\t\n')
    f.write('\n')
    
    for i in currentImageFiles:
     length = length - 1
     print length
     #print curdir
     #print currentImageFiles[1]
     f.write('\t\n')
     f.write('\t\t595.0\n')
     f.write('\t\t' + curdir + '/' + currentImageFiles[length] +'\n')
     f.write('\t\n')
     f.write('\t\n')
     f.write('\t\t5.0\n')
     f.write('\t\t' + curdir + '/' + currentImageFiles[length] + '\n')
     if length >= 1:
      f.write('\t\t' + curdir + '/' + currentImageFiles[length-1] + '\n')
     if length <1:
      f.write('\t\t' + curdir + '/' + currentImageFiles[len(currentImageFiles)-1] + '\n')
     f.write('\t\n')
    
    f.write('\n')
    f.close()

     3. 将生成的background.xml加入桌面背景选择中

附录:

 
     
    2009 
    08 
    04 
    00 
    00 
    00 
   
   
    
    1800.0   
    /usr/share/backgrounds/cosmos/cloud.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/cloud.jpg 
    /usr/share/backgrounds/cosmos/comet.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/comet.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/comet.jpg 
    /usr/share/backgrounds/cosmos/earth-horizon.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/earth-horizon.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/earth-horizon.jpg 
    /usr/share/backgrounds/cosmos/blue-marble-west.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/blue-marble-west.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/blue-marble-west.jpg 
    /usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg 
    /usr/share/backgrounds/cosmos/helix-nebula.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/helix-nebula.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/helix-nebula.jpg 
    /usr/share/backgrounds/cosmos/jupiter.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/jupiter.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/jupiter.jpg 
    /usr/share/backgrounds/cosmos/sombrero.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/sombrero.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/sombrero.jpg 
    /usr/share/backgrounds/cosmos/whirlpool.jpg 
   
   
    1800.0 
    /usr/share/backgrounds/cosmos/whirlpool.jpg 
   
   
    5.0 
    /usr/share/backgrounds/cosmos/whirlpool.jpg 
    /usr/share/backgrounds/cosmos/cloud.jpg 
   
 

你可能感兴趣的:(Ubuntu,Comet,F#,OS,Python)