import random
from gi.repository import Gio
+from wand.image import Image
+from wand.color import Color
+from wand.drawing import Drawing
+
APP_NAME = 'bluberblubb'
+fsize_title = 16
+fsize_subtitle = 11
+font = '/usr/share/fonts/corefonts/verdanab.ttf'
+
def get_desktop_environment():
#From http://stackoverflow.com/questions/2035657/what-is-my-current-desktop-environment
# and http://ubuntuforums.org/showthread.php?t=652320
raise KeyError("Neither USERPROFILE or HOME environment variables set.")
bg_dirs = [
- '/home/fbrehm/Bilder/Wallpaper',
- '/home/frank/Bilder/bg',
+ #'/home/fbrehm/Bilder/Wallpaper',
+ '/home/frank/Bilder',
'/usr/share/backgrounds',
]
print("Current Wallpaper: %r." % (cur_wpaper))
print("Setting Wallpaper to: %r." % (wpaper))
-#if os.path.exists(wpaper) and os.path.isfile(wpaper):
-# gsettings.set_string(KEY, wpaper)
+if os.path.exists(wpaper) and os.path.isfile(wpaper):
+ gsettings.set_string(KEY, wpaper)
+
+title = os.path.basename(wpaper)
+title = re.sub(r'\.[^\.]*$', '', title)
+new_img_fname = '/tmp/wallpaper.jpg'
+
+old_img = Image(filename = wpaper)
+new_img = old_img.clone()
+
+black = Color('srgba(0,0,0,0.5)')
+white = Color('srgba(255,255,255,0.5)')
+
+draw = Drawing()
+
+draw.fill_color = white
+draw.stroke_color = black
+draw.text_antialias = True
+draw.text_alignment = 'center'
+draw.stroke_width = 1
+draw.text_encoding = 'utf-8'
+draw.font = font
+draw.font_size = fsize_title
+
+fm = draw.get_font_metrics(new_img, title, False)
+x = int(new_img.width / 2)
+y = int(fm.text_height)
+#print("Koordinaten: x %r, y %r." % (x, y))
+draw.text(x, y, title)
+
+draw.font_size = fsize_subtitle
+fm = draw.get_font_metrics(new_img, wpaper, False)
+x = int(new_img.width / 2)
+y = int(fm.text_height) + y + 5
+#print("Koordinaten: x %r, y %r." % (x, y))
+draw.text(x, y, wpaper)
+
+draw(new_img)
+
+new_img.save(filename = new_img_fname)
+
+
+
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4