~ubuntu-branches/ubuntu/trusty/ubuntukylin-wallpapers/trusty-proposed

« back to all changes in this revision

Viewing changes to update-background.py

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-03-03 11:47:10 UTC
  • Revision ID: package-import@ubuntu.com-20130303114710-cdyfcr7fan2fr1so
Tags: 13.10.0
Initial release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import glob
 
4
 
 
5
PREAMBLE = """<background>
 
6
  <starttime>
 
7
    <year>2009</year>
 
8
    <month>08</month>
 
9
    <day>04</day>
 
10
    <hour>00</hour>
 
11
    <minute>00</minute>
 
12
    <second>00</second>
 
13
  </starttime>
 
14
<!-- This animation will start at midnight. -->
 
15
"""
 
16
 
 
17
ENTRY = """  <static>
 
18
    <duration>1795.0</duration>
 
19
    <file>%(a)s</file>
 
20
  </static>
 
21
  <transition>
 
22
    <duration>5.0</duration>
 
23
    <from>%(a)s</from>
 
24
    <to>%(b)s</to>
 
25
  </transition>
 
26
"""
 
27
 
 
28
FOOTER = """</background>
 
29
"""
 
30
 
 
31
PATH='/usr/share/backgrounds/'
 
32
 
 
33
def main():
 
34
    images = glob.glob('*.jpg')
 
35
    m = len(images)
 
36
 
 
37
    output = ''
 
38
    output += PREAMBLE 
 
39
    for i in xrange(m):
 
40
        output += ENTRY % {'a': PATH + images[i], 'b': PATH + images[(i+1) % m]}
 
41
    output += FOOTER
 
42
    print output,
 
43
 
 
44
if __name__ == '__main__':
 
45
    main()