2 """Print background filename
4 Print the filename of the current or previous background image.
6 This file is a part of XSetBg.
10 __author__ = "Oleg Broytman <phd@phdru.name>"
11 __copyright__ = "Copyright (C) 2004-2012 PhiloSoft Design"
12 __license__ = "GNU GPL"
15 import sys, os, shelve
19 sys.stderr.write("Usage: %s [-o|--old]\n" % sys.argv[0])
24 from getopt import getopt, GetoptError
27 options, arguments = getopt(sys.argv[1:], "ho", ["help", "old"])
33 for option, value in options:
34 if option in ("-h", "--help"):
36 elif option in ("-o", "--old"):
49 xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
52 global_db_name = "xsetbg.db"
53 filename_key = "filename"
54 old_filename_key = "old_filename"
57 global_db = shelve.open(global_db_name, flag='r')
59 key = old_filename_key
62 filename = global_db[key]
65 from m_lib.defenc import default_encoding
66 filename = unicode(filename, default_encoding)
68 print filename.encode(default_encoding)