Open plugin from your own menu in E2

  • Starting a plugin directly in enigma1 (like from your own menu), could be done by code like this:


    eZapPlugins plugins(2);
    plugins.execPluginByName("plugin.cfg");



    Is there a similar easy way to open a plugin directly in Enigma2, without going through the plugin menu ?


  • I am trying to run a plugin from menu.xml directly, without calling the pluginbrowser module.


    If I put your line in a screen module (say Test1) _init_ function, I get an error - Test1 does not have an attribute open.


    Will you kindly explain where this code can be implemented ?


    Regards, pcd.

  • Maybe you mean this:

    Code
    def main(session,**kwargs):
        session.open(OwnClass)


    or this:

    Python
    class OwnClass(Screen):
    ...
        def runPlugin(self):
            from Plugins.Extensions.OwnPlugin.plugin import ClassName
            self.session.open(ClassName)

    MfG Ali

    DM8000 | DM8000 | DM500HD | DM500HD | DM7020S


    Bash
    #!/bin/sh
    while [ 1 ]
    do
    	echo "i love my dreams!!!"
    	sleep 1
    done
  • I think the more important part was the missing "self.open" which Ali correctly changed into self.session.open or session.open (depends where you have the session).


    If you only have the bytecode you are kinda helpless. You could "debug" the Plugin beforehand (read out definition of Plugins) and afterwards call the function which would normally be called where you want it.
    But I think if the author only gives you the bytecode he might not want you to do that and you should contact him before you do anything else :winking_face:

    Homescreen eurer Apple-Geräte noch nicht voll genug?


    dreaMote: Fernbedienung für Dreamboxen
    Mobile WOL: Wake-on-LAN Client für iOS mit optionalem Widget
    My Home Remote: Fernkontrolle für Homematic CCU/CCU2 optimiert für mobile Benutzung

  • Ok, I was a little bored and as nobody seemed to listen to my advice anyway I decided to implement this bad and hackish (!!!!) workaround myself (Plugins should add themselves to the menu if they need to be there.... this way the menu entry is always shown no matter if the plugin is installed or not).


    Easier part: Add Function to Menu


    Add the following code at a place in the menu where you want it to reside. In this example we're adding an entry for the plugin SimpleRSS (hence the item text).

    Code
    <item text="SimpleRSS"><screen module="PluginOpener" screen="PluginOpener" /></item>


    The Screen (Module) PluginOpener will be explained now...


    Harder part: Write a wrapper function



    We're creating a dummy Screen PluginOpener which has no content and - when initialized (as its the first possible moment) - opens the Plugin (Function "openPlugin").
    In this fnc we first import the plugins main function (which we need to know, as explained in an earlier post this could be done automatically but I'm not supposed to do all the work for you ;)), then call it with the expected arguments (session for functions which are called from PluginMenu or ExtensionMenu) and close the helper screen (as we're using onShown for opening the plugin it would just be reopened otherwise - trust me, I forgot to close the window at first :))


    PS: Sorry for posting this badly formatted text but I really thought my explanation would at least be read as it included all the needed bits which I implemented in the sample above.

    Homescreen eurer Apple-Geräte noch nicht voll genug?


    dreaMote: Fernbedienung für Dreamboxen
    Mobile WOL: Wake-on-LAN Client für iOS mit optionalem Widget
    My Home Remote: Fernkontrolle für Homematic CCU/CCU2 optimiert für mobile Benutzung