RetroFlag cases for the Raspberry can commonly be found on Amazon, have classic gaming console design, and have hardware buttons for both powering off and restarting. RetroFlag has its own official script on GitHub to get the hardware buttons functioning, the problem is this script is geared towards RetroPie and do not work on OSMC.
After hours of looking at various different methods and scripts to get the buttons to work, I came across one that is using systemd instead of rc.local and it was pretty simple to modify to get OSMC supported.
Device: Raspberry Pi 3 B+
OSMC Version: 2019.4-1
RetroFlag Case: SUPERPi CASE-U
Fan GPIO Pins: pin 1 (3.3v)/pin 9 (Ground)
Installing a fan is optional, though the RetroFlag cases do have a spot inside for one to be installed. Some resellers of the cases include a 30mmx30mm 5V fan. The pre-installed PCB inside the case does have a dedicated fan header, I did not use this for MY setup.
For the fan installation instructions I followed Setting up Your Retroflag NESPi Case with a Heatsink and Cooling Fan. The only thing I did differently was I installed my fan to
pin 1 (3.3v) and
pin 9 (Ground) to minimize noise.
NOTE: Safe Shutdown script successfully stops fan from running on shutdown with my fan setup. I personally have not tested other fan setups.
Connect to Raspberry Pi via SSH as
ssh osmc@<IP ADDRESS>
Install the dependencies:
sudo apt-get update sudo apt-get install python3 python3-dev python3-setuptools python3-pip gcc sudo pip3 install wheel sudo pip3 install rpi.gpio
Download ZIP from repository, and extract the contents:
wget https://gitlab.com/syst3mfailur3/retroflag-picase/-/archive/master/retroflag-picase-master.zip unzip retroflag-picase-master.zip
Enter into newly extracted directory and run the install script:
cd retroflag-picase-master sudo sh install.sh osmc
When prompted, enter Y to reboot.
NOTE: Currently this the scripts files are from my fork of the original repo, will update to main repo if/when my pull request is accepted.