"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
__license__ = "GNU GPL"
-import os, shelve
from operator import itemgetter
+from xsetbg_db import xsetbg_db
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
-
-global_db = shelve.open(global_db_name, flag='r')
-for key, value in sorted(global_db.items(), key=itemgetter(1), reverse=1):
+for key, value in sorted(xsetbg_db.items(), key=itemgetter(1), reverse=1):
if key.startswith('/'):
print value, key
-global_db.close()
+xsetbg_db.close()
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
__license__ = "GNU GPL"
-import os, shelve
from time import localtime, asctime
-
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
+from xsetbg_db import xsetbg_db
count = 0
oldest = None
-global_db = shelve.open(global_db_name, flag='r')
-for key in global_db.keys():
+for key in xsetbg_db.keys():
count += 1
- if key.startswith('/') and ((oldest is None) or (global_db[key] < oldest)):
- oldest = global_db[key]
-global_db.close()
+ if key.startswith('/') and ((oldest is None) or (xsetbg_db[key] < oldest)):
+ oldest = xsetbg_db[key]
+xsetbg_db.close()
print count, "files"
print "Oldest:", asctime(localtime(oldest))
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2006-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2006-2014 PhiloSoft Design"
__license__ = "GNU GPL"
-import os, shelve
from operator import itemgetter
+from xsetbg_db import xsetbg_db
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
-
-global_db = shelve.open(global_db_name, flag='r')
-for key, value in sorted(global_db.items(), key=itemgetter(1), reverse=1):
+for key, value in sorted(xsetbg_db.items(), key=itemgetter(1), reverse=1):
if key.startswith('/'):
print key
-global_db.close()
+xsetbg_db.close()
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2007-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2007-2014 PhiloSoft Design"
__license__ = "GNU GPL"
-import sys, os, shelve
+import sys, shelve
+from xsetbg_db import xsetbg_db_path
-xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
-os.chdir(xsetbg_dir)
-
-global_db_name = "xsetbg.db"
dump_file = open(sys.argv[1], 'rU')
-global_db = shelve.open(global_db_name, flag='n')
+xsetbg_db = shelve.open(xsetbg_db_path, flag='n')
for line in dump_file:
timestamp, filename = line.strip().split(None, 1)
- global_db[filename] = float(timestamp)
-global_db.close()
+ xsetbg_db[filename] = float(timestamp)
+xsetbg_db.close()
dump_file.close()
port = 7999
[xsetbg]
+database = ~/lib/xsetbg/xsetbg.db
+
; minimum time in seconds between background image changes
min_pause = 300 ; (5 minutes)
from time import time
from xsetbg_conf import xsetbg_dir, xsetbg_conf
-from xsetbg_db import xsetbg_db_name, xsetbg_db
+from xsetbg_db import xsetbg_db
def error(error_str, error_code=1):
# readable only by the user
try:
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), flag='c')
+ xsetbg_db = shelve.open(xsetbg_db_path, flag='c')
except anydbm.error, msg:
if str(msg) == "db type could not be determined":
- os.remove(xsetbg_db_name)
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), flag='c')
+ os.remove(xsetbg_db_path)
+ xsetbg_db = shelve.open(xsetbg_db_path, flag='c')
# Remove old filenames
old_time = time() - min_delay
xsetbg_db = None
try:
# Reopen the global persistent dictionary
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), 'w')
+ xsetbg_db = shelve.open(xsetbg_db_path, 'w')
timestamp = xsetbg_db.get(timestamp_key)
current_time = time()
__all__ = ['xsetbg_db']
import anydbm
-import os
import shelve
-from xsetbg_conf import xsetbg_dir, xsetbg_conf
+from xsetbg_conf import xsetbg_conf
-xsetbg_db_name = "xsetbg.db"
+xsetbg_db_path = xsetbg_conf.get('xsetbg', 'database')
try:
- xsetbg_db = shelve.open(os.path.join(xsetbg_dir, xsetbg_db_name), 'r')
+ xsetbg_db = shelve.open(xsetbg_db_path, 'r')
except anydbm.error:
xsetbg_db = None