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-2014 PhiloSoft Design"
12 __license__ = "GNU GPL"
16 from xsetbg_conf import xsetbg_conf
17 from xsetbg_db import xsetbg_db
21 sys.stderr.write("Usage: %s [-o|--old]\n" % sys.argv[0])
26 from getopt import getopt, GetoptError
29 options, arguments = getopt(sys.argv[1:], "he:o",
30 ["help", "output-encoding=", "old"])
35 output_encoding = None
37 for option, value in options:
38 if option in ("-h", "--help"):
40 elif option in ("-e", "--output-encoding"):
41 output_encoding = value
42 elif option in ("-o", "--old"):
50 if output_encoding is None:
51 from m_lib.defenc import default_encoding
52 output_encoding = default_encoding
53 return old, output_encoding
55 old, output_encoding = get_args()
58 filename_key = "filename"
59 old_filename_key = "old_filename"
62 key = old_filename_key
66 filename = xsetbg_db[key]
69 fs_encoding = xsetbg_conf.get("images", "fs_encoding")
70 filename = unicode(filename, fs_encoding)
72 print filename.encode(output_encoding)