]> git.phdru.name Git - xsetbg.git/blobdiff - xsetbg.py
min_delay = 6 months.
[xsetbg.git] / xsetbg.py
index 865a5eea9f925fb6ec2a8ce27b02665571772684..c2b994887464a2d6a700ee1ebdeea67080c7fb91 100755 (executable)
--- a/xsetbg.py
+++ b/xsetbg.py
@@ -1,8 +1,9 @@
-#! /usr/local/bin/python -O
+#! /usr/bin/env python
 """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.
 
 """
 
@@ -107,6 +108,12 @@ os.umask(0066) # octal; -rw-------; make the global persistent dictionary
 global_db_name = "xsetbg.db"
 
 
+# DB keys
+timestamp_key = "timestamp"
+filename_key = "filename"
+old_filename_key = "old_filename"
+
+
 import random
 import anydbm, shelve
 from time import time
@@ -126,23 +133,20 @@ except anydbm.error, msg:
 # Remove old filenames
 old_time = time() - min_delay
 
-to_delete = []
+to_delete = [timestamp_key]
 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]
+   try:
+      del global_db[key]
+   except KeyError:
+      pass
 
 global_db.close() # Close DB in the parent process
 
 
-# DB keys
-timestamp_key = "timestamp"
-filename_key = "filename"
-old_filename_key = "old_filename"
-
-
 images = []
 
 for image_dir in image_dirs: