If you would like to use the nespi case which has reset and power off buttons. I have used the following scripts from https://github.com/Denisuu/OSMC_NesPi-SuperPi_Safe-Shutdown
I made the following changes for dietPi:
From the readme.md I changed these steps:
Step 2 run:
mkdir -p /home/dietpi/scripts && cd /home/dietpi/scripts && wget https://raw.githubusercontent.com/Denisuu/OSMC_NesPi-SuperPi_Safe-Shutdown/master/multi_switch.sh && chmod +x multi_switch.sh
For step 3:
I create a autostart service call nespi (sudo nano /etc/systemd/system/nespi.service)
The content are of the nespi.service are :
[Unit]
Description=Nespi GPIO Init
After=network.target
[Service]
ExecStart=/home/dietpi/scripts/multi_switch.sh --nespi+
[Install]
WantedBy=multi-user.target
To test nespi service run
sudo systemctl daemon-reload
sudo systemctl start nespi.service
To add the nespi service to autostart
sudo systemctl enable nespi.service
Credits to Denisuu for creating the script!