Adding plugins to main menu

Janso

TK Veteran
I've got a Vu with Kodi installed at my parents' house and I've had a few backup images on it from other sites but I wanted to make my own. Now on these backups, there's been Kodi on the main menu, and I want to do that in my image.

I would have asked the people who put together the backups I've used previously but they're no longer active on the websites I found them, so that rules that out.

I know it's easy enough to access through the plugins screen but it just makes it easier for them to get it open.

Anybody know how I can do this?


Sent from my iPhone using Tapatalk
 
There was a plugin to do this if memory serves, or you would have to manually edit some of the python code. I can't remember any other way unless it has been added in the year or so I've been out of the sat scene.
 
I am bored today, so I have done googling for you.

You come across as a guy that likes to faff, so pull up a chair... :faint:

You can do this by editting the plugin.py of kodi.

plugins on your box live in one of 2 folders in

/usr/lib/enigma2/python/Plugins

find your kodi plugin folder. Inside that you will have Plugin.pyo or Plugin.py.
If you have only got the compiled pyo version. Either hunt down the original uncomplied version, or use Easy python decompiler (google it)
decompiler will make a file called plugin.pyo_dis. Just rename it Plugin.py and edit it with something like notepad.

Now somewhere in plugin.py file is the section where it is displayed on your box.

def Plugins(**kwargs):

In there you will have a command similar to below.

where = [ PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU ],
icon="./icon.png",
fnc=main)

you need to to change it to or add in the main menu.

where = [ PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_MENU ],
icon="./icon.png",
fnc=menu)


Reupload your new plugin.py and reboot your box.

That is in principle how you do it.
 
Last edited:
Okay so this is the code that resembles what you've given me (thank you by the way, I'd seen that thread on the forum that shall not be named but I had no idea which part I needed to edit). I changed the pluginmenu section to menu and the fnc= to mainmenu and it didn't seem to do anything

HTML:
def Plugins(**kwargs):    l = []    l.append(PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=session_start_main))    l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("start kodi(formerly known as XBMC) mediacenter"), where=PluginDescriptor.WHERE_PLUGINMENU, fnc=plugin_start_xbmc))    return l

Also copied what you said more closely

HTML:
def Plugins(**kwargs):    l = []    l.append(PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=menu))    l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("start kodi(formerly known as XBMC) mediacenter"), where=PluginDescriptor.WHERE_MAINMENU, fnc=plugin_start_xbmc))    return l

but this also seemed to do nothing.

Well, kind of. Both gave me a message saying that the thing I put next to the first fnc= wasn't available when I went to check if it was still in the plugins menu. So nothing that I wanted it to do, and it's also made it inaccessible. I do have the original file backed up though, something I learned while pissing about with your skin files. :)



I'm probably missing something very simple here but can't quite manage to make the connection. Got me feeling a little like this - :anyonethere:
 
zip up the originally plugin file and post it on here. (go advanced add attachment) I don't use kodi so don't have access to the file.
 
try again, that is a corrupt zip file. or just post the full def Plugins(**kwargs): section here.
 
This is the full section -

def Plugins(**kwargs):
l = []
l.append(PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=session_start_main))
l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("start kodi(formerly known as XBMC) mediacenter"), where=PluginDescriptor.WHERE_PLUGINMENU, fnc=plugin_start_xbmc))
return l
 
so possible it should be

def Plugins(**kwargs):
l = []
l.append(PluginDescriptor(where=PluginDescriptor.W HERE_SESSIONSTART, fnc=session_start_main))
l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("start kodi(formerly known as XBMC) mediacenter"), where=PluginDescriptor.WHERE_MENU, fnc=plugin_start_xbmc))
return l


or

def Plugins(**kwargs):
l = []
l.append(PluginDescriptor(where=PluginDescriptor.W HERE_SESSIONSTART, fnc=session_start_main))
l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("start kodi(formerly known as XBMC) mediacenter"), where=PluginDescriptor.WHERE_MENU, fnc=menu))
return l

---------- Post Merged at 02:34 PM ----------

this is the dreamplex plugin code. This shows on the main menu

def Plugins(**kwargs):
myList = []
boxResolution = getBoxResolution()
if boxResolution == 'FHD':
myList.append(PluginDescriptor(name='DreamPlex', description='plex client for enigma2', where=[PluginDescriptor.WHERE_PLUGINMENU], icon='pluginLogoHD.png', fnc=main))
else:
myList.append(PluginDescriptor(name='DreamPlex', description='plex client for enigma2', where=[PluginDescriptor.WHERE_PLUGINMENU], icon='pluginLogo.png', fnc=main))
myList.append(PluginDescriptor(where=PluginDescriptor.WHERE_AUTOSTART, fnc=Autostart))
myList.append(PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=sessionStart))
if config.plugins.dreamplex.showInMainMenu.value:
myList.append(PluginDescriptor(name='DreamPlex', description=_('plex client for enigma2'), where=[PluginDescriptor.WHERE_MENU], fnc=menu_dreamplex))
return myList


---------- Post Merged at 02:45 PM ----------

I think we are missing a step. Whatever is referenced in the fnc needs to be defined in the plugin.py.

I will have a play and add one of the other plugins to the main menu and see what actually needs to be done.
 
Last edited:
Tried both of these, the second one won't let me open the menu at all and the first one doesn't do it.

I'll see if I can find anything else about it though.



Ah, hadn't tried your edits there. I'll have a play with the things you've just added to the post and let you know if any of them work. Appreciate your help.
 
right....

i have just tried this with epg importer.

original code

Code:
def epgmenu(menuid, **kwargs):
    if getImageDistro() in ('openvix', 'openbh', 'ventonsupport', 'egami', 'openhdf'):
        if menuid == 'epg':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              1002)]
        else:
            return []
    elif getImageDistro() in 'openatv':
        if menuid == 'epg':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              None)]
        else:
            return []
    elif getImageDistro() in 'openmips':
        if menuid == 'epg_menu':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              95)]
        else:
            return []
    else:
        if menuid == 'setup':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              1002)]
        return []
    return None


def Plugins(**kwargs):
    result = [
    PluginDescriptor(name=_('EPG-Importer'), description=description, where=[PluginDescriptor.WHERE_AUTOSTART,PluginDescriptor.WHERE_SESSIONSTART], fnc=autostart, wakeupfnc=getNextWakeup),
    PluginDescriptor(name=_('EPG-Importer'), description=description, where=PluginDescriptor.WHERE_PLUGINMENU, icon='plugin.png', fnc=main),
    PluginDescriptor(name=_('EPG-Importer'), description=description, where=PluginDescriptor.WHERE_MENU, fnc=epgmenu)
    ]
    if config.plugins.epgimport.showinextensions.value:
        result.append(extDescriptor)
    if config.plugins.epgimport.showinplugins.value:
        result.append(pluginlist)
    return result

new code in red and green below

Code:
def epgmenu(menuid, **kwargs):
    if getImageDistro() in ('openvix', 'openbh', 'ventonsupport', 'egami', 'openhdf'):
        if menuid == 'epg':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              1002)]
        else:
            return []
    elif getImageDistro() in 'openatv':
        if menuid == 'epg':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              None)]
        else:
            return []
    elif getImageDistro() in 'openmips':
        if menuid == 'epg_menu':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              95)]
        else:
            return []
    else:
        if menuid == 'setup':
            return [(_('EPG-Importer'),
              main,
              'epgimporter',
              1002)]
        return []
    return None


[COLOR=#008000][B]def mymenu(menuid, **kwargs):
    if menuid == "mainmenu":
        return [(_("EPG-Importer"), main, "epgimporter", 44)]
    return [][/B][/COLOR]
    
def Plugins(**kwargs):
    result = [
    PluginDescriptor(name=_('EPG-Importer'), description=description, where=[PluginDescriptor.WHERE_AUTOSTART, PluginDescriptor.WHERE_SESSIONSTART], fnc=autostart, wakeupfnc=getNextWakeup),
    PluginDescriptor(name=_('EPG-Importer'), description=description, where=PluginDescriptor.WHERE_PLUGINMENU, icon='plugin.png', fnc=main),
    PluginDescriptor(name=_('EPG-Importer'), description=description, where=PluginDescriptor.WHERE_MENU, fnc=epgmenu),
   [B][COLOR=#ff0000] PluginDescriptor(name=_('EPG-Importer'), description=description, where=PluginDescriptor.WHERE_MENU, [/COLOR][COLOR=#008000]fnc=mymenu[/COLOR][COLOR=#ff0000])[/COLOR][/B]
    ]
    if config.plugins.epgimport.showinextensions.value:
        result.append(extDescriptor)
    if config.plugins.epgimport.showinplugins.value:
        result.append(pluginlist)
    return result

so add in a new main menu line with your own menu function.
Then define this function, using existing code references for kodi.
In my example EPG-Importer is the description - epgimporter is what is called when I press the menu option. 44 is the pecking order. Increase or decrease it to move it up or down the menu list. Menu items by default are ordered 0,10,20,30,40... etc

custom-image.jpg

---------- Post Merged at 03:25 PM ----------

and if you can't work it out.... ;)

Code:
[COLOR=#ff0000][B]def mymenu(menuid, **kwargs):
    if menuid == "mainmenu":
        return [(_("Kodi"), main, "Kodi", 44)]
    return [][/B][/COLOR]
    

def Plugins(**kwargs):
    l = []
    l.append(PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=session_start_main))
    l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("Start Kodi mediacenter"), where=PluginDescriptor.WHERE_PLUGINMENU, fnc=plugin_start_xbmc))
  [COLOR=#ff0000][B]  l.append(PluginDescriptor(name=_("Kodi"), description=_("Kodi"), where=PluginDescriptor.WHERE_MENU, fnc=mymenu))[/B][/COLOR]
    return l

simple in the end. Ha ha.
But we like to learn.

---------- Post Merged at 03:44 PM ----------

??? have you got it working ???
 
Last edited:
Doesn't seem to have worked, it isn't on the menu and it says there's a bad block (237) in the python - is it important where the def mymenu goes? as I just put this in above the plugins part as you have above.
 

Attachments

  • j88sLGM - Imgur.png
    j88sLGM - Imgur.png
    27.5 KB · Views: 61
no but python is fussy. It all has to be tabbed correctly and no random spaces before or after lines of code.

i.e correct

Code:
def mymenu(menuid, **kwargs):
    if menuid == "mainmenu":
        return [(_("EPG-Importer"), main, "epgimporter", 4)]
    return []

wrong

Code:
def mymenu(menuid, **kwargs):
if menuid == "mainmenu":
return [(_("EPG-Importer"), main, "epgimporter", 4)]
return []

run it through a python checker.
PEP8 online check

---------- Post Merged at 03:52 PM ----------

there will be lots of errors like line to long etc, but just look at the lines of code you have entered.

---------- Post Merged at 03:54 PM ----------

A good test is to delete the original pyo file. If there is an error it won't compile so you wont get a new pyo file on reboot.
 
Last edited:
skafUqz.png

Okay this is what that's giving me. Trying to work out where the obvious things I can change are but the line too long messages I'm unsure on how to deal with.
 
you can edit the code live in that python checker until its correct.

ignore line too long.
delete all tabs and reapply them.
Remove any line breaks and create another. (removing the tab it will create)
remove surplus spaces it's moaning about i.e around ==
and you need two blank lines after the menu declaration. my mistake.

---------- Post Merged at 04:14 PM ----------

i have editted my code on post 11. I think I might have been missing an underscore and tidied up the spaces.
 
Last edited:
Just trying to amend the latest edit on your post 11 to make the checker happy as I'm still getting a few messages.

Then I'll try and it'll hopefully give me some joy...


If nothing else, I'm learning a little about python code, which I never expected.
 
if you are still struggling, start from scratch with the original py code and manually type in the new stuff. Instead of cut and pasting.
This forum code is probably bringing in different formatting.

Code:
[COLOR=#ff0000][B]def mymenu(menuid, **kwargs):
    if menuid == "mainmenu":
        return [(_("Kodi"), main, "Kodi", 44)]
    return [][/B][/COLOR]
    

def Plugins(**kwargs):
    l = []
    l.append(PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=session_start_main))
    l.append(PluginDescriptor(name=_("Kodi Launcher"), description=_("Start Kodi mediacenter"), where=PluginDescriptor.WHERE_PLUGINMENU, fnc=plugin_start_xbmc))
  [COLOR=#ff0000][B]  l.append(PluginDescriptor(name=_("Kodi"), description=_("Kodi"), where=PluginDescriptor.WHERE_MENU, fnc=mymenu))[/B][/COLOR]
    return l

---------- Post Merged at 04:27 PM ----------

and try notepad instead of notepad++. Notepad++ is probably also trying to format the code (usually badly)

---------- Post Merged at 04:28 PM ----------

i am using dreamweaver which is designed for code input. So i don't have these format problems.
 
Nope, it's still not liking it.

Think I'll just give this up as a bad job so as to not take up any more of your time - thank you anyway for trying.
 
i am sat on my computer doing other things anyway.
Try zipping the original plugin.pyo again.

If you have failed I will try editting it for you and see how we get on.
 
Back
Top