Context Item Add-ons
Context item add-ons allows the Context menu in Kodi to be extended. Add-ons must provide the kodi.context.item
extension point and a item definition as follows:
<item> <label></label> <visible></visible> <parent></parent> </item>
<label>: Required. The label to show in the context menu. String or an ID from the language file.
<visible>: Required. A visibility expression that determines when the item will be visible in the context menu.
<parent>: Optional. The parent group for the context item. If "kodi.core.manage" the item will be added under the "Manage" sub-menu. If not specified, it will be added to the top level.
It is currently only possible to provide one item per add-on.
Note: Before adding a context menu extension to existing add-on, keep in mind that there is limited space in the context menu and that having multiple extension in and add-on will force the user to have all of them enabled at the same time.
Example addon.xml
definition:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="context.item.hello.world" name="Hello World" version="1.0.0" provider-name="your-name"> <requires> <import addon="xbmc.python" version="2.20.0"/> </requires> <extension point="kodi.context.item" library="addon.py"> <item> <label>Hello World</label> <visible>!IsEmpty(ListItem.Genre)</visible> </item> </extension> <extension point="kodi.addon.metadata"> <platform>all</platform> <summary></summary> <description></description> </extension> </addon>
Example python script:
The item the context menu was opened on can be accessed in python via the sys.listitem
attribute. The attribute is an instance of
xbmcgui.ListItem
. The following example script will display a notification message showing the name of item:
import sys
import xbmc
if __name__ == '__main__':
message = "Clicked on '%s'" % sys.listitem.getLabel()
xbmc.executebuiltin("Notification(\"Hello context items!\", \"%s\")" % message)