add not random dynamic type

This commit is contained in:
elwld 2022-08-13 16:18:26 +05:00
parent 2f6f6ff725
commit 65236d5671

View File

@ -67,6 +67,17 @@ def setRandomWallpaper(path):
wallpaperName = path+random.choices(os.listdir(path))[0] wallpaperName = path+random.choices(os.listdir(path))[0]
setWallpaper(wallpaperName) setWallpaper(wallpaperName)
def setNextWallpaper(path):
if 'wallpaperIndex' not in globals():
globals()['wallpaperIndex'] = -1
global wallpaperIndex
wallpaperIndex+=1
wallpaperName = path + sorted(os.listdir(path))[wallpaperIndex%len(os.listdir(path))]
setWallpaper(wallpaperName)
def setTheme(themeName = None, nightMode = False): def setTheme(themeName = None, nightMode = False):
config = getConfig() config = getConfig()
@ -77,10 +88,9 @@ def setTheme(themeName = None, nightMode = False):
theme = config[themeName] theme = config[themeName]
if theme["type"] == "static": if theme["type"] == "static":
try: if "random" in theme and theme["random"]:
if theme["random"]: setRandomWallpaper(theme["path"]) setRandomWallpaper(theme["path"])
else: setWallpaper(theme["url"]) else:
except KeyError:
setWallpaper(theme["url"]) setWallpaper(theme["url"])
elif theme["type"] == "dynamic": elif theme["type"] == "dynamic":
@ -91,9 +101,21 @@ def setTheme(themeName = None, nightMode = False):
delay = delay[0] + delay[1]*60 + delay[2]*3600 delay = delay[0] + delay[1]*60 + delay[2]*3600
random = False
if "random" in theme and theme["random"]:
random = True
if 'threadIsAlive' not in globals():
globals()['threadIsAlive'] = True
global threadIsAlive global threadIsAlive
while threadIsAlive: while threadIsAlive:
setRandomWallpaper(theme["path"]) if random:
setRandomWallpaper(theme["path"])
else:
setNextWallpaper(theme["path"])
sleep(delay) sleep(delay)
else: else: