def set_background(afile=None): desktop_environment = get_desktop_environment() if desktop_environment == 'gnome' or desktop_environment == 'unity' or \ desktop_environment == 'budgie-desktop': if afile and os.path.exists(afile): os.system("DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set \ org.gnome.desktop.background picture-uri file://'%s'" % afile) elif desktop_environment == "mate": if afile and os.path.exists(afile): os.system("DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set \ org.mate.background picture-filename '%s'" % afile) elif desktop_environment == "cinnamon": if afile and os.path.exists(afile): os.system("DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set \ org.cinnamon.desktop.background picture-uri file://'%s'" % afile)
def set_background(afile=None): if afile and os.path.exists(afile): local.env['DISPLAY'] = ':0' local.env['GSETTINGS_BACKEND'] = 'dconf' gsettings = local['gsettings'] desktop_environment = get_desktop_environment() if desktop_environment == 'gnome' or \ desktop_environment == 'unity' or \ desktop_environment == 'budgie-desktop': gsettings['set', 'org.gnome.desktop.background', 'picture-uri', 'file://{}'.format(afile)]() elif desktop_environment == "mate": gsettings['set', 'org.mate.desktop.background', 'picture-filename', '\'{}\''.format(afile)]() elif desktop_environment == "cinnamon": gsettings['set', 'org.cinnamon.desktop.background', 'picture-uri', 'file://{}'.format(afile)]()
def __init__(self): self.cron = CronTab(user=True) params = PARAMS % os.getuid() filename = os.path.join(os.path.expanduser('~'), FILE) desktop_environment = get_desktop_environment() if desktop_environment == 'gnome' or \ desktop_environment == 'unity' or \ desktop_environment == 'budgie-desktop': gset = GSET_GNOME % filename elif desktop_environment == "mate": gset = GSET_MATE % filename elif desktop_environment == "cinnamon": gset = GSET_CINNAMON % filename else: gset = None if gset is not None: self.command = 'sleep 20;{0};{1} {2} {4} && {3} {4}'.format( params, EXEC, SCRIPT, gset, NO_OUTPUT) else: self.command = None