{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihxfmvzgrdiupx5j5puabimdrjpms453hv37igd2jdybyi5ds2n2m",
"uri": "at://did:plc:yxhvd47p53gmb5zfiktqq3og/app.bsky.feed.post/3moho4nffea24"
},
"canonicalUrl": "https://handyman5.github.io//posts/nespi-case-led-light-and-buttons-script",
"path": "/posts/nespi-case-led-light-and-buttons-script",
"publishedAt": "2026-06-14T00:00:00.000Z",
"site": "at://did:plc:yxhvd47p53gmb5zfiktqq3og/site.standard.publication/3mohn6mqvab25",
"tags": [
"emulation"
],
"textContent": "I have a NESPi Case for my RetroPie emulation console. It has a little red LED light on the front and I wanted it to work. However, after I installed Lakka (which is great in all other respects), I couldn't figure out how.\n\nI spent some time figuring it out, and now you get to reap the benefits of my investigation.\n\n\nSetup\n\nFirst things first, I should list what hardware I'm using so you have an idea of whether this might be relevant for you.\n\n Board: Raspberry Pi 3 Model B Plus Rev 1.3\n Case: NESPi Case Plus\n* OS: Lakka, a Linux distribution that packages RetroArch and basically nothing else\n\nThe case has a red LED light and Power and Reset buttons, along with a GPIO header for the Raspberry Pi that connects them. The case manufacturers have a repo that includes a script to read those headers and do useful things (reboot when the buttons are pressed, turn on the light, etc.). I wanted the red light to turn on while the machine is running, because of course.\n\nInvestigation\n\nUnfortunately, that script is not designed to work on Lakka, which (as I mentioned before) does not include many of the niceties of a modern Linux distribution like a package manager.\n\nSomeone put together a version of the script that _is_ supposed to work on Lakka, but it hasn't been touched in 8 years and it didn't work on my machine when I tried:\n\nThe repo includes a precompiled version of the GPIO library that doesn't work with the current version of the kernel (Lakka switched to aarch64 in 2021, which postdates this repo), and there aren't any trivial ways to get a new version cross-compiled and uploaded. But, luckily for us, Lakka started including the python-raspberry-gpio package in 2021, which installs the lgpio python package (relevant package docs). This is not a drop-in replacement for the RPi.GPIO library (which is what the precompiled binary includes); if you do need such a replacement, apparently rpi-lgpio will do the trick. But as I mentioned, Lakka does not have a package installation mechanism (including pip), so I had to rewrite the manufacturers' script to use lgpio instead of RPi.GPIO.\n\nScript\n\nTo save you all the trouble, here's the new script:\n\n<details>\n<summary>said script</summary>\n\n</details>\n\nThis enables the power LED and also the button functionality (which I don't ever use, but while I was in the neighborhood).\n\nInstallation\n\nI put the new script in /storage/scripts/shutdown.py like the old Lakka-installing repo's installation script did. That script also adds a line to /storage/.config/autostart.sh which is Lakka's mechanism for automatically starting programs on boot. The only change I had to make was to have the autostart bit cd to /tmp before running the new python script, because otherwise I was getting weird permissions errors:\n\nRunning the script from a working directory where it has proper permissions did the trick.\n\nWrapup\n\nThis was a fun evening's investigation and hopefully it'll prove useful to somebody someday. Good luck and happy emulating!",
"title": "NESPi Case LED Light and Buttons Script"
}