]> git.phdru.name Git - xsetbg.git/blobdiff - print-filename.py
Version 4.0.0
[xsetbg.git] / print-filename.py
index 0c8e8f9369b61158082ac8aac92945bd45415ecc..91088c25a5752e690d43c0a571f8ed056f757550 100755 (executable)
@@ -24,15 +24,19 @@ def get_args():
    from getopt import getopt, GetoptError
 
    try:
-      options, arguments = getopt(sys.argv[1:], "ho", ["help", "old"])
+      options, arguments = getopt(sys.argv[1:], "he:o",
+                                  ["help", "output-encoding=", "old"])
    except GetoptError:
       usage(1)
 
    old = False
+   output_encoding = None
 
    for option, value in options:
       if option in ("-h", "--help"):
          usage()
+      elif option in ("-e", "--output-encoding"):
+         output_encoding = value
       elif option in ("-o", "--old"):
          old = True
       else:
@@ -41,9 +45,12 @@ def get_args():
    if arguments:
       usage(3)
 
-   return old
+   if output_encoding is None:
+      from m_lib.defenc import default_encoding
+      output_encoding = default_encoding
+   return old, output_encoding
 
-old = get_args()
+old, output_encoding = get_args()
 
 
 xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
@@ -62,7 +69,11 @@ else:
 filename = global_db[key]
 global_db.close()
 
-from m_lib.defenc import default_encoding
-filename = unicode(filename, default_encoding)
+from ConfigParser import SafeConfigParser
+config = SafeConfigParser()
+config.read("xsetbg.conf")
 
-print filename.encode(default_encoding)
+fs_encoding = config.get("images", "fs_encoding")
+filename = unicode(filename, fs_encoding)
+
+print filename.encode(output_encoding)