Skip to content

Commit

Permalink
added support for MATE desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
GabMus committed Feb 23, 2018
1 parent 869d017 commit 406ba45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions hydrapaper/__main__.py
Expand Up @@ -579,8 +579,13 @@ def on_wallpapersFlowbox_child_activated(self, flowbox, selected_item):
)

def apply_button_async_handler(self, monitors):
desktop_environment = os.environ.get('XDG_CURRENT_DESKTOP')
if desktop_environment == 'MATE':
wp_setter_func = WallpaperMerger.set_wallpaper_mate
else:
wp_setter_func = WallpaperMerger.set_wallpaper_gnome
if len(monitors) == 1:
WallpaperMerger.set_wallpaper(monitors[0].wallpaper, 'zoom')
wp_setter_func(monitors[0].wallpaper, 'zoom')
return
#if len(self.monitors) != 2:
# print('Configurations different from 2 monitors are not supported for now :(')
Expand All @@ -602,7 +607,7 @@ def apply_button_async_handler(self, monitors):
saved_wp_path
)
)
WallpaperMerger.set_wallpaper(saved_wp_path)
wp_setter_func(saved_wp_path)

def set_favorite_state(self, wp_path, wp_widget, isfavorite):
if isfavorite:
Expand Down
12 changes: 10 additions & 2 deletions hydrapaper/wallpaper_merger.py
Expand Up @@ -8,7 +8,7 @@

TMP_DIR='/tmp/HydraPaper/'

def multi_setup_pillow(monitors, save_path):
def multi_setup_pillow(monitors, save_path, wp_setter_func=None):
images = list(map(Image.open, [m.wallpaper for m in monitors]))
resolutions = [(m.width, m.height) for m in monitors]
widths = [r[0] for r in resolutions]
Expand All @@ -22,9 +22,17 @@ def multi_setup_pillow(monitors, save_path):
final_image.paste(i, o)
final_image.save(save_path)

def set_wallpaper(path, wp_mode='spanned'):
def set_wallpaper_gnome(path, wp_mode='spanned'):
gsettings = Gio.Settings.new('org.gnome.desktop.background')
wp_key = 'picture-uri'
mode_key = 'picture-options'
gsettings.set_string(wp_key, 'file://{}'.format(path))
gsettings.set_string(mode_key, wp_mode)

def set_wallpaper_mate(path, wp_mode='spanned'):
gsettings = Gio.Settings.new('org.mate.background')
wp_key = 'picture-filename'
mode_key = 'picture-options'
gsettings.set_string(wp_key, path)
gsettings.set_string(mode_key, wp_mode)

0 comments on commit 406ba45

Please sign in to comment.