FWIW, here’s my code. It appears to work as expected, from a local folder anyway.
import xbmc
from os import listdir
from time import sleep
xbmc.log('[refresh-slideshow] Starting')
monitor = xbmc.Monitor()
picfolder = "/home/osmc/images"
# Generate list of images and start slideshow
l1 = listdir(picfolder)
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
xbmc.log('[refresh-slideshow] Slideshow started, monitoring')
# Wait for slideshow to start
sleep(5)
# Monitor during slideshow
while not monitor.abortRequested():
# If slideshow is still running, compare directory contents
if xbmc.getCondVisibility('Window.IsActive(slideshow)'):
l2 = listdir(picfolder)
# Restart slideshow if directory contents have changed
if l1 != l2:
xbmc.log('[refresh-slideshow] Folder contents changed, restarting slideshow')
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
l1 = l2
# If slideshow is no longer running (user has exited), exit script
else:
break
# Wait for 60 seconds, break if abort is requested
if monitor.waitForAbort(60):
break
xbmc.log('[refresh-slideshow] Finished, exiting')