import xbmc
import xbmcaddon
import time

ADDON = xbmcaddon.Addon()

def run():
    # Wait a moment for Kodi to fully start
    xbmc.sleep(1000)
    from changelog_window import check_and_show_changelog, get_saved_version
    addon_path = ADDON.getAddonInfo('path')
    addon_version = ADDON.getAddonInfo('version')
    # Only show changelog if not already seen for this version
    if get_saved_version() != addon_version:
        check_and_show_changelog(addon_path)
        xbmc.sleep(500)  # Allow state to persist
    # Launch ten buttons interface
    addon_id = ADDON.getAddonInfo('id')
    xbmc.executebuiltin(f'RunPlugin(plugin://{addon_id}/?action=show_ten_buttons)')

if __name__ == '__main__':
    monitor = xbmc.Monitor()
    run()
    while not monitor.abortRequested():
        if monitor.waitForAbort(1):
            break