Kodi Community Forum

Full Version: How to programmatically reload/refresh the skin?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to trigger a rebuild/refresh of the skin?  Like when you make a change to the Main Menu layout and it rebuilds with the changes - is there a way to trigger this without having to make a token change to the layout?

I'm trying to find a way to trigger said rebuild/refresh whenever a profile is logged into because profiles break widgets.
There is ReloadSkin() as a built-in function.
Thank you Klojum!  Is there any way to trigger that each time a user profile logs in?
(2022-02-12, 15:29)beeswax Wrote: [ -> ]Is there any way to trigger that each time a user profile logs in?

I would've thought that a skin is being rebuilt/redrawn anyway whenever someone logs in, so I'm kinda lost to what other context you might be referring to.
Sorry, I should have been clearer, the issue I'm trying to solve is detailed here.  Basically Aeon Nox Silvo widgets don't like User Profiles at all - whenever you switch profiles, widgets are retained from the other profile or not drawn at all.  In both cases, making a small layout change and triggering a skin rebuild/refresh fixes it.  So what I'm trying to figure out is a way to trigger such a rebuild/refresh at each logon.  Is this possible?  If not natively maybe some obscure addon which can run scripts on events or something?

I'm kind of desperate to get this to work because I won't be able to keep using Kodi in the lounge if I can't filter out unsuitable content properly.  I've done all the work of creating smart playlists which give me exactly what I need in each profile but the widget bug means it's all for naught.
I've figured this out.  AutoExec.py is the way to run a python script at each logon.

For the script itself, turns out ReloadSkin() isn't enough, I don't know whether this is an Aeon Nox specific thing or a SkinShortcuts thing but the only way I could figure out to trigger a menu rebuild was making a change to \.kodi\userdata\profiles\<profile>\addon_data\script.skinshortcuts\mainmenu.DATA.xml.   I needed a unique string which would never be in there normally so added the string "ClegNut" in the following section:
Quote:<shortcut>
        <defaultID>favourites</defaultID>
        <label>1036</label>
        <label2 />
        <icon>special://skin/extras/icons/ClegNut.png</icon>
        <thumb />
        <action>ActivateWindow(Favourites)</action>
        </shortcut>
    <shortcut>

I chose the .png reference as I don't believe those .png files are actually used anywhere.  Here's the autoexec.py:

python:
import xbmc
  
skinprops = xbmc.translatePath('special://profile/addon_data/script.skinshortcuts/mainmenu.DATA.xml')
    
f = open(skinprops,'r')
filedata = f.read()
f.close()

if "BumNugget" in filedata:

    newdata = filedata.replace("BumNugget","ClegNut")
    
else:
    newdata = filedata.replace("ClegNut","BumNugget")
    
f = open(skinprops,'w')
f.write(newdata)
f.close()

Now at every logon, Nuts will be swapped with Nuggets and a menu rebuild will be triggered.  I still see the placeholders for the incorrect or broken widgets every time someone logs in but very quickly, the "Building menu" bar appears at the top which triggers a full main menu rebuild and the correct ones load.  I still hope Mike or someone can figure out why this happens and fix it properly.