]> git.phdru.name Git - xsetbg.git/blobdiff - xsetbg.py
Better docstring.
[xsetbg.git] / xsetbg.py
index 93791a4ef38830d5e0e4dacc1be9b0c49cc057b6..472196690efecb018e87de06a9c802e232adcaef 100755 (executable)
--- a/xsetbg.py
+++ b/xsetbg.py
@@ -1,8 +1,9 @@
 #! /usr/local/bin/python -O
 """Set a random background image (XWin)
 
-Select a random image from $HOME/lib/xsetbg/images subdirectories
-and set it as the desktop wallpaper (display it in the root window).
+Select a random image from a (list of) directory(s)
+and set it as the desktop wallpaper (display it in the root window)
+using xli or xsetbg programs.
 
 """
 
@@ -123,7 +124,18 @@ except anydbm.error, msg:
       os.remove(global_db_name)
       global_db = shelve.open(global_db_name, flag='c')
 
-global_db.close() # Close DB in parent process
+# Remove old filenames
+old_time = time() - min_delay
+
+to_delete = []
+for key in global_db.keys():
+   if key.startswith('/') and global_db[key] < old_time:
+      to_delete.append(key)
+
+for key in to_delete:
+   del global_db[key]
+
+global_db.close() # Close DB in the parent process
 
 
 # DB keys