Refresh Picture Library



I am running the OSMC on a raspberry pi. I have set up file sharing using smb and the source of my pictures are on a shared folder in my LAN.

As I run the slideshow, I realised that pictures added into the shared folder does not appear on the slideshow. How do I scan and refresh the library so that the slideshows include the latest added pictures while running?

With the Watchdog add on I can refresh the folder as I exit the slideshow, but I would like the slideshow to update in real time. Is this possible?



I do not think this is possible at the moment


Get currently shown image of Slideshow

Thanks Sam!

I found this on the Kodi forum.

Would adding a script like this for OSMC work?

Thanks again.


I created the script above and placed it in /home/osmc/scripts

As I run the above script which I named it says:

This is my full script

What might have gone wrong?

Thanks in advance.


I would also love to get this functionality (auto refresh directory during picture slideshow). Did you ever get it working?


I managed to get this working, sort of.

I created a new shortcut within /home/osmc/.kodi/userdata/favourites.xml:

    <favourite name="Slideshow">RunScript(/home/osmc/</favourite>

I then created a new file /home/osmc/

import xbmc

from time import sleep
from os import listdir

minutes = 1
picfolder = "/home/osmc/images"

l1 = []
while 1:
 l2 = listdir(picfolder)
 if (l1 != l2):
   xbmc.executebuiltin('xbmc.slideshow(' + picfolder + ')')
   l1 = l2
 for seconds in range(minutes * 60):

Note: The Python code is from this thread.

Starting the script from the favourites menu runs a slideshow of images from the folder. The code checks for changes in the directory every minute and restarts the slideshow if anything changes, effectively functioning as an ‘auto refresh’. This works as expected.

Unfortunately I haven’t found a way to stop the script from running. If you exit the slideshow, the Python code keeps running in the background and will restart the slideshow if the folder contents change. Not ideal.

Perhaps the above is useful for someone.

If anyone can suggest a straightforward way to have the script stop running once the slideshow has ended I’d appreciate any pointers. I’m sure it’s possible, but it is probably beyond my skill level…

Edit for future reference: Perhaps look at using xbmc.getCondVisibility(Slideshow.IsActive) ?


SlideShow.IsActive is absolutely the way to check whether the slideshow is running. You should also check to see if Kodi is shutting down as otherwise your script can block its exit. Something like the following (and totally untested):

import xbmc
from os import listdir

monitor = xbmc.Monitor()
picfolder = "/home/osmc/images"

l1 = listdir(picfolder)
while not monitor.abortRequested():
    if xbmc.getCondVisibility('Slideshow.IsActive'):
        l2 = listdir(picfolder)
        if l1 != l2:
            xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
            l1 = l2
    if monitor.waitForAbort(60):
        # Abort was requested while waiting for 60 seconds. We should exit


Fantastic, thanks a lot for the pointers and sample to test. I’ll give this a go when I get a chance and report back with results.


OK, I’m stuck.

If I start a slideshow from within my Python script, then enter a checking loop to see if it is still running, then the value of xbmc.getCondVisibility('Slideshow.IsActive') is always 1 - even if I subsequently stop the slideshow from within Kodi using the remote control.

Form this and other testing, it appears (to me anyway) that the value of Slideshow.IsActive gets set to 1 when a slideshow is started, but doesn’t get reset to 0 when it is terminated. I am a novice at this, so I may be wrong. Sounds like I now need input from the Kodi team…


This is a Kodi specific issue that you should address there. OSMC has no bearing on your problem. More relevant info should be available there.


Whilst ActionA is absolutely correct that this is a Kodi issue and needs to be reported on their forums so it can be fixed, whilst you’re waiting a fix (and you really REALLY need to report this to those who are responsible for fixing it) you could potentially use Window.IsActive(slideshow) until your report results in a fix.


Thanks. I realise this is not an OSMC issue, hence the last sentence of my post. I will raise this over at their forum.

Edit: Thanks for the tip @BobCrachett - I might try that in the interim and see if I have more luck.

Edit 2: Confirmed and logged as a Kodi bug . Using Window.IsActive(slideshow) in the interim appears to work!


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

# 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
    # Wait for 60 seconds, break if abort is requested
    if monitor.waitForAbort(60):

xbmc.log('[refresh-slideshow] Finished, exiting')


Hi there,

I’m having the same issue and thanks to you guys I could solve it. So it’s restarting the slideshow and showing new pics.
However, I have one thing that could be improved and I don’t know how to do it. As the slideshow gets restarted, it’ll show pictures again and again, even if they were shown a couple of seconds before. Shuffle mode helps a bit but some pics are shown more often than others.

Do you have an idea how to “prioritize” pics that weren’t shown yet, so that they get shown first?