Enable/Disable all input by button press

  • Nice, the “Enabling“ part is working now, the working script is the following:

    Bash
    #!/bin/sh
    rm /storage/.kodi/userdata/keymaps/keyboard.xml
    sleep 1
    kodi-send -a "Action(reloadkeymaps)"
    sleep 1
    kodi-send -a "Notification(Kodi Info,Keyboard Enabled,7000,http://powerpi.de/wp-content/uploads/powerpi/powerpi_ambi_thumb_off.jpg)"
    </dev/null >/dev/null 2>&1 &

    Now i have two keyboard.xml files, one is numb and the other is full.

    The full is the exact copy of the /usr/share/kodi/system/keymaps/keyboard.xml plus the following entry:

    Code
          <!-- PVR -->
          <red>ActivateWindow(TVChannels)</red>
          <green>ActivateWindow(Videos)</green>
          <yellow>ActivateWindow(Music)</yellow>
          <blue>XBMC.RunScript(/storage/.kodi/userdata/turnoff_keyboard.sh)</blue>
          <!-- Multimedia keyboard keys -->
          <browser_back>Back</browser_back>

    The numb is the exact copy off vpeter file, only replacing my script:

    However, when i press the blue button nothing happens :(

    Here are the code of my two .sh scripts:

    TurnOn:

    Bash
    #!/bin/sh
    cp /storage/.kodi/userdata/bkpmaps/fullkeyboard.xml /storage/.kodi/userdata/keymaps/keyboard.xml
    sleep 1
    kodi-send -a "Action(reloadkeymaps)"
    sleep 1
    kodi-send -a "Notification(Kodi Info,Keyboard Enabled,7000,http://powerpi.de/wp-content/uploads/powerpi/powerpi_ambi_thumb_off.jpg)"
    </dev/null >/dev/null 2>&1 &

    TurnOff:

    Bash
    #!/bin/sh
    cp /storage/.kodi/userdata/bkpmaps/numbkeyboard.xml /storage/.kodi/userdata/keymaps/keyboard.xml
    kodi-send -a "Action(reloadkeymaps)"
    sleep 1
    kodi-send -a "Notification(Kodi Info,Keyboard Disabled,7000,http://powerpi.de/wp-content/uploads/powerpi/powerpi_ambi_thumb_off.jpg)"
    </dev/null >/dev/null 2>&1 &

    I think im next to my final goal but still missing something ?(

  • XBMC.RunScript can execute only python script I think. I think the best would be to rewrote above script to python. To copy file use How do I copy a file in Python? - Stack Overflow and for notification xbmc.executebuiltin('Notification.

    Maybe something like

    Python
    #!/usr/bin/python
    
    import xbmc
    from shutil import copyfile
    
    copyfile('/storage/.kodi/userdata/bkpmaps/numbkeyboard.xml', '/storage/.kodi/userdata/keymaps/keyboard.xml')
    xbmc.executebuiltin('Action(reloadkeymaps)')
    xbmc.executebuiltin('Notification(Kodi Info, Keyboard Disabled, 7000, http://powerpi.de/wp-content/uploads/powerpi/powerpi_ambi_thumb_off.jpg)')
  • Hi, when i run the script above i get:

    Code
    Traceback (most recent call last):
      File "turnoff_keyboard.py", line 3, in <module>
        import xbmc
    ImportError: No module named xbmc

    im running directly from bash with python scriptname.py since from remote it didint worked also.

  • You can't run such script directly because module xbmc is only available when running from kodi.

    But you can run

    Code
    kodi-send --action="RunScript(/storage/..../TurnOn.py)"
  • I made it work by setting it run from Left key, but is not working for blue key, i tested with the following map:

    I can confirm the color keys (red,blue,green,yellow) works when i have my full keyboard map. But is not working to call the script, if i press left, it works correctly.

  • Enable debug in kodi, press blue key and check what you got in log.

    Try using this one for blue button:

    Code
    <m mod="ctrl">XBMC.RunScript(/storage/.kodi/userdata/turnon_keyboard.py)</m> -->    <!-- blue button, MCE My music -->

    All 4 buttons from https://kodi.wiki/view/list_of_mce_remote_controls

    Code
    <t mod="ctrl,shift">Notification(Key, Yellow, 3)</t> <!-- Yellow button -->
    <m mod="ctrl">Notification(Key, Blue, 3)</m>         <!-- Blue button -->
    <i mod="ctrl">Notification(Key, Green, 3)</i>        <!-- Green button -->
    <e mod="ctrl">Notification(Key, Red, 3)</e>          <!-- Red button -->
  • Thank you! For some reason, my blue key was mapped to <e> key. Now i finally can use my remote for both Kodi and my TV. Its Solved!

    Thank you so much for your help, i would never make it without it.

    Cheers