]> Frank Brehm's Git Trees - my-stuff/python.git/commitdiff
Minor changes
authorFrank Brehm <frank@brehm-online.com>
Sun, 25 May 2014 11:21:47 +0000 (13:21 +0200)
committerFrank Brehm <frank@brehm-online.com>
Sun, 25 May 2014 11:21:47 +0000 (13:21 +0200)
DE-env.py

index 1d22498ed45dd796c8f5023eafa782372b0d58bb..4a87564d3b5526dc99fc434a4c4fa7b65e40873e 100755 (executable)
--- a/DE-env.py
+++ b/DE-env.py
@@ -383,15 +383,28 @@ if os.path.exists(wpaper) and os.path.isfile(wpaper):
 title = os.path.basename(wpaper)
 title = re.sub(r'\.[^\.]*$', '', title)
 title = re.sub(r'_+', ' ', title)
+log.debug("New title from filename: %r", title)
 new_img_fname = '/tmp/wallpaper.jpg'
 
 old_img = Image(filename = wpaper)
 new_img = old_img.clone()
 
 exif = {}
+comment = None
+re_comment = re.compile(r'^comment\s*$', re.IGNORECASE)
 for k, v in old_img.metadata.items():
     exif[k] = v
+    if re_comment.search(k):
+        comment = v
 log.debug("Found Metadata:\n%s", pp(exif))
+if comment:
+    log.debug("Found comment: %r", comment)
+    for line in comment.splitlines():
+        line = line.strip()
+        if line:
+            title = line
+            log.debug("New title from comment: %r", title)
+            break
 
 (screen_width, screen_height) = get_max_monitor_geometry()
 new_height = screen_height