LibreELEC - Kodi 17.x - Python Add-on to run a GUI based on XML. Need to monitor/detect SD card insertion from that python add on

  • I'm working on an Add-on to drive a custom GUI on a LibreELEC system on Linux. The add-on works fine and is able to drive the GUI as needed.

    At the linux level - LE has udev rules that detect when an SD card is inserted and it works fine, KODI interface generates a notification on bottom right corner as device is added or removed.

    I want my Python add-on to react to the SD card addition or removal event and make changes to the GUI. Users on Kodi forum suggested I use PyUdev module. But as LE does not come with PIP, I cannot install that module.

    Please advice on how to detect/react to SD Card insertion/removal in a Python add-on.

    Thanks in advance.

  • Try downloading and unpacking pyudev package and use it manually from your script. Like

    Code
    import sys
    sys.path.append('pyudev-0.21.0/src')
    sys.path.append('six-1.12.0')
    
    import six
    import pyudev