add not random dynamic type
This commit is contained in:
parent
2f6f6ff725
commit
65236d5671
@ -67,6 +67,17 @@ def setRandomWallpaper(path):
|
||||
wallpaperName = path+random.choices(os.listdir(path))[0]
|
||||
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):
|
||||
config = getConfig()
|
||||
@ -77,10 +88,9 @@ def setTheme(themeName = None, nightMode = False):
|
||||
theme = config[themeName]
|
||||
|
||||
if theme["type"] == "static":
|
||||
try:
|
||||
if theme["random"]: setRandomWallpaper(theme["path"])
|
||||
else: setWallpaper(theme["url"])
|
||||
except KeyError:
|
||||
if "random" in theme and theme["random"]:
|
||||
setRandomWallpaper(theme["path"])
|
||||
else:
|
||||
setWallpaper(theme["url"])
|
||||
|
||||
elif theme["type"] == "dynamic":
|
||||
@ -91,9 +101,21 @@ def setTheme(themeName = None, nightMode = False):
|
||||
|
||||
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
|
||||
while threadIsAlive:
|
||||
setRandomWallpaper(theme["path"])
|
||||
if random:
|
||||
setRandomWallpaper(theme["path"])
|
||||
else:
|
||||
setNextWallpaper(theme["path"])
|
||||
sleep(delay)
|
||||
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user