font = '/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf'
opacity = 0.6
+DEFAULT_MIN_WIDTH = 800
+DEFAULT_MIN_HEIGTH = 600
+
#-------------------------------------------------------------------------
def init_logging():
"""
raise KeyError("Neither USERPROFILE or HOME environment variables set.")
#-------------------------------------------------------------------------
-def get_max_monitor_height():
+def get_max_monitor_geometry():
- max_height = 768
+ max_width = DEFAULT_MIN_WIDTH
+ max_height = DEFAULT_MIN_HEIGTH
screen = Gdk.Screen.get_default()
if screen is None:
- return max_height
+ log.debug("No screen found, returning %d x %d.", max_width, max_height)
+ return (max_width, max_height)
monitors = []
nmons = screen.get_n_monitors()
for m in range(nmons):
mg = screen.get_monitor_geometry(m)
log.debug("Monitor geometry %d: %d x %d", m, mg.width, mg.height)
+ if mg.width > max_width:
+ max_width = mg.width
if mg.height > max_height:
max_height = mg.height
- return max_height
+ return (max_width, max_height)
#-------------------------------------------------------------------------
bg_dirs = [
old_img = Image(filename = wpaper)
new_img = old_img.clone()
-screen_height = get_max_monitor_height()
+(screen_width, screen_height) = get_max_monitor_geometry()
+new_height = screen_height
new_width = int(float(old_img.width) / float(old_img.height) * float(screen_height))
+if new_width < screen_width:
+ new_width = screen_width
+ new_height = int(float(old_img.height) / float(old_img.width) * float(screen_width))
log.debug("Old image size: %d x %d.", old_img.width, old_img.height)
+log.debug("Calculated new image size: %d x %d.", new_width, new_height)
x_plus = int(float(new_width) * 1.01)
x_minus = int(float(new_width) * 0.99)
-y_plus = int(float(screen_height) * 1.01)
-y_minus = int(float(screen_height) * 0.99)
+y_plus = int(float(new_height) * 1.01)
+y_minus = int(float(new_height) * 0.99)
if (old_img.width < x_minus or old_img.width > x_plus or
old_img.height < y_minus or old_img.height > y_plus):
- log.debug("Resizing image to %d x %d.", new_width, screen_height)
- new_img.resize(new_width, screen_height)
+ log.debug("Resizing image to %d x %d.", new_width, new_height)
+ new_img.resize(new_width, new_height)
black = Color('srgba(0,0,0,%0.1f)' % (opacity))
white = Color('srgba(255,255,255,%0.1f)' % (opacity))
fm = draw.get_font_metrics(new_img, title, False)
x = int(new_img.width / 2)
y = int(fm.text_height)
-log.debug("Koordinaten: x %r, y %r.", x, y)
+log.debug("Koordinaten Titel: 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
-log.debug("Koordinaten: x %r, y %r.", x, y)
+log.debug("Koordinaten Untertitel: x %r, y %r.", x, y)
draw.text(x, y, wpaper)
draw(new_img)