def load_plugin():
    """Adds EV3 buttons on toolbar and commands under Run and Tools menu. Add EV3 configuration window."""

    # Add EV3 configuration window
    workbench=get_workbench()
    workbench.set_default("ev3.ip", "192.168.0.1")
    workbench.set_default("ev3.username", "robot")
    workbench.set_default("ev3.password", "maker")
    workbench.add_configuration_page("EV3", Ev3ConfigurationPage)


    # icons

    image_path_remoterun = os.path.join(os.path.dirname(__file__), "res", "remoterun.gif")
    image_path_remotedebug = os.path.join(os.path.dirname(__file__), "res", "remotedebug.gif")


    image_path_upload = os.path.join(os.path.dirname(__file__), "res", "up.gif")
    image_path_run = os.path.join(os.path.dirname(__file__), "res", "flash.gif")
    image_path_log = os.path.join(os.path.dirname(__file__), "res", "log.gif")

    image_path_clean = os.path.join(os.path.dirname(__file__), "res", "clean.gif")





    # menu buttons

    get_workbench().add_command("ev3remoterun", "run", "Run current script using the EV3 API in remote control mode" ,
                                get_button_handler_for_magiccmd_on_current_file("Ev3RemoteRun"),
                                currentscript_and_command_enabled,
                                default_sequence="<F9>",
                                group=20,
                                image_filename=image_path_remoterun,
                                include_in_toolbar=True)
    get_workbench().add_command("ev3remotedebug", "run", "Debug current script using the EV3 API in remote control mode" ,
                                get_button_handler_for_magiccmd_on_current_file("Ev3RemoteDebug"),
                                currentscript_and_command_enabled,
                                default_sequence="<Control-F9>",
                                group=20,
                                image_filename=image_path_remotedebug,
                                include_in_toolbar=True)

    get_workbench().add_command("ev3patch", "tools", "Install ev3dev additions to the ev3dev sdcard on the EV3",
                                patch_ev3,
                                command_enabled,
                                default_sequence=None,
                                group=270,
                                #image_filename=image_path_upload,
                                include_in_toolbar=False)

    get_workbench().add_command("ev3softreset", "tools", "Soft reset the EV3  (stop programs,rpyc started sound/motors,restart brickman and rpycd service)",
                                soft_reset_ev3,
                                command_enabled,
                                default_sequence=None,
                                group=275,
                                #image_filename=image_path_clean,
                                include_in_toolbar=False)



    get_workbench().add_command("ev3upload", "tools", "Upload current script to EV3",
                                upload_current_script,
                                currentscript_and_command_enabled,
                                default_sequence="<F10>",
                                group=280,
                                image_filename=image_path_upload,
                                include_in_toolbar=True)
    get_workbench().add_command("ev3run", "tools", "Start current script on the EV3",
                                start_current_script,
                                currentscript_and_command_enabled,
                                default_sequence="<Control-F10>",
                                group=280,
                                image_filename=image_path_run,
                                include_in_toolbar=True)
    get_workbench().add_command("ev3log", "tools", "Download log of current script from EV3",
                                download_log_of_current_script,
                                currentscript_and_command_enabled,
                                default_sequence=None,
                                group=280,
                                image_filename=image_path_log,
                                include_in_toolbar=True)

    get_workbench().add_command("ev3clean", "tools", "Cleanup EV3 by deleting all files stored in homedir on EV3",
                                cleanup_files_on_ev3,
                                command_enabled,
                                default_sequence=None,
                                group=290,
                                image_filename=image_path_clean,
                                include_in_toolbar=True)



    orig_interrupt_backend=get_runner().interrupt_backend
    def wrapped_interrupt_backend():

        # kill program on pc
        orig_interrupt_backend()

        # stop programmings running on ev3 and stop sound/motors via rpyc
        stop_ev3_programs__and__rpyc_motors_sound()


    get_runner().interrupt_backend = wrapped_interrupt_backend



    # magic commands
    shell = get_workbench().get_view("ShellView")

    shell.add_command("Ev3RemoteRun", _handle_rundebug_from_shell)
    shell.add_command("Ev3RemoteDebug", _handle_rundebug_from_shell)


    shell.add_command("Reset", _handle_reset_from_shell)

    shell.add_command("pwd", _handle_pwd_from_shell)
    shell.add_command("cd", _handle_cd_from_shell)
    shell.add_command("ls", _handle_ls_from_shell)
    shell.add_command("help", _handle_help_from_shell)
    shell.add_command("open", _handle_open_from_shell)
    shell.add_command("reload", _handle_reload_from_shell)