2 """Print background filename
4 Print the filename of the current or previous background image.
6 This file is a part of XSetBg.
10 __version__ = "$Revision$"[11:-2]
11 __revision__ = "$Id$"[5:-2]
12 __date__ = "$Date$"[7:-2]
14 __author__ = "Oleg BroytMann <phd@phd.pp.ru>"
15 __copyright__ = "Copyright (C) 2004-2007 PhiloSoft Design"
16 __license__ = "GNU GPL"
19 import sys, os, shelve
23 sys.stderr.write("Usage: %s [-o|--old]\n" % sys.argv[0])
28 from getopt import getopt, GetoptError
31 options, arguments = getopt(sys.argv[1:], "ho", ["help", "old"])
37 for option, value in options:
38 if option in ("-h", "--help"):
40 elif option in ("-o", "--old"):
53 xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
56 global_db_name = "xsetbg.db"
57 filename_key = "filename"
58 old_filename_key = "old_filename"
61 global_db = shelve.open(global_db_name, flag='r')
63 key = old_filename_key
66 filename = global_db[key]
69 from m_lib.defenc import default_encoding
70 filename = unicode(filename, default_encoding)
72 print filename.encode(default_encoding)