This is an old revision of the document!


Default.py

Introduction

default.py contains the main Python code of an addon. This document describes sample code that may be used in default.py.

xbmc.python.script Addon

xbmc.service Addon

Open Addon Settings on First Run

Restart Service when Settings are Changed

The code below restarts the system.d service of an addon when settings of the addon are changed. import subprocess import xbmc import xbmcaddon class Monitor(xbmc.Monitor): def __init__(self, *args, **kwargs): xbmc.Monitor.__init__(self) self.id = xbmcaddon.Addon().getAddonInfo('id') def onSettingsChanged(self): subprocess.call([['systemctl',|'restart', self.id]]) if __name__ == '__main__': Monitor().waitForAbort()