#import gconf
import random
from gi.repository import Gio
+from gi.repository import Gdk
import logging
from wand.image import Image
if not os.path.exists(font):
font = '/usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf'
+#-------------------------------------------------------------------------
def init_logging():
"""
Initialize the logger object.
init_logging()
+#-------------------------------------------------------------------------
def get_desktop_environment():
#From http://stackoverflow.com/questions/2035657/what-is-my-current-desktop-environment
# and http://ubuntuforums.org/showthread.php?t=652320
return "kde"
return "unknown"
+#-------------------------------------------------------------------------
def is_running(process):
#From http://www.bloggerpolis.com/2011/05/how-to-check-if-a-process-is-running-using-python/
# and http://richarddingwall.name/2009/06/18/windows-equivalents-of-ps-and-kill-commands/
sys.stderr.write("ERROR: Failed to set wallpaper. There might be a bug.\n")
return False
+#-------------------------------------------------------------------------
def get_config_dir(app_name=APP_NAME):
if "XDG_CONFIG_HOME" in os.environ:
confighome = os.environ['XDG_CONFIG_HOME']
else:
raise KeyError("Neither USERPROFILE or HOME environment variables set.")
+#-------------------------------------------------------------------------
+def get_max_monitor_height():
+
+ max_height = 768
+ screen = Gdk.Screen.get_default()
+ if screen is None:
+ return max_height
+
+ monitors = []
+ nmons = screen.get_n_monitors()
+ log.debug("There are %d monitors.", nmons)
+
+ 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.height > max_height:
+ max_height = mg.height
+
+ return max_height
+
+#-------------------------------------------------------------------------
bg_dirs = [
#'/home/fbrehm/Bilder/Wallpaper',
'/home/frank/Bilder',
old_img = Image(filename = wpaper)
new_img = old_img.clone()
+screen_height = get_max_monitor_height()
+new_width = int(float(old_img.width) / float(old_img.height) * float(screen_height))
+
+log.debug("Resizing image to %d x %d.", new_width, screen_height)
+new_img.resize(new_width, screen_height)
+
black = Color('srgba(0,0,0,0.5)')
white = Color('srgba(255,255,255,0.5)')