Multi Switch Shutdown Script!
-
@denisuu I don't use OSMC so make sure the directory
/lib/systemd/system-shutdown/
is available (I think it is available)So in your tutorial follow steps till 2b
-
sudo nano /etc/rc.local
3.1 add above line exit 0python /home/osmc/shutdown.py &
3.2 or/home/osmc/shutdown.py &
alone can also work ;) -
setup script according to link from me
4.1 change led_pin from 17 to 14
4.2 poweroff_pin = 4 is okay
No... 5 is physical pin 5 = GPIO 3 so magic are the lines
import RPi.GPIO as GPIO ..... GPIO.setmode(GPIO.BOARD)
in the python script. -
-
Thanks for the help, really appreciate it!!!
It's partially working now, now it goes to sleep and the fans keep spinning like in the original script.
I actually have a Retroflag SUPERpi case (on the other 2 scripts it dind't make a difference).the power-switch acts a little funny now. Up is reboot and down is sleep.
All steps done: https://pastebin.com/4QcLQY7M
Edit: It's reacts exactly the same on Raspbian.
-
@denisuu Does the LED blink 3 times? You have to make the gpio shutoff script executable with chmod command. This is essential forget this to mention
Edit it is command
sudo chmod +x /lib/systemd/system-shutdown/gpio-shutoff
-
Yes it blinks 3 times and powers off then after af few seconds turns on again,
or goes to sleep (depending on the possition of the switch).I did make the script executable I forgot to add it to the pastbin. (added it now)
-
@denisuu are there any other scripts running? It is a bit hard to guess but you can try to use the original fan_shutdown script. Please install raspi-gpio with
sudo apt-get install raspi-gpio
-
Ok I removed the old script on Raspbian and installed yours, it works perfectly now!
Only OSMC left, it's really sad it doens't work on OSMC since that's what I use my pi most often for. OSMC doesn't find the package raspi-gpio or npm. Can I just disable the FAN on that partition? Or get raspi-gpio from somewhere else?
Raspbian:
296 cd /home/pi/ 297 ls -alF 298 rm reset.py 299 rm shutdown.py 300 rm /lib/systemd/system/shutdown.service 301 apt install raspi-gpio 302 mkdir /home/pi/scripts 303 cd /home/pi/scripts 304 wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh r/multi_switch.sh && chmod +x multi_switch.sh 305 ls -alF 306 sudo nano /etc/rc.local (/home/pi/scripts/multi_switch.sh --nespi+ & before exit 0) 307 cd /lib/systemd/system-shutdown/ && sudo wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/shutdown_fan && sudo chmod +x shutdown_fan nt.com/crcerror/ES-generic-shutdown/master/shutdown_fan && sudo chmod +x shutdownfan
-
@denisuu I think in OSMC it is easily possible to add that function, too. You can try wiringPi instead - I think that should be available. So every call to raspi-gpio must be translated to a wPi call.
EDIT:
I think you should usesudo apt-get install build-essential
and then you can further start your build -
I deleted half of the scipt and it still works, would it be possible to delete everything I don't need from this? That would make it a lot easier to translate it to WiringPi, since I don't understand half of what the script does.
-
@denisuu You can delete 95% if the script and it will still work. Instead of the raspi-gpio try to translate to wpi calls. Did you try to compile raspi-gpio? https://github.com/RPi-Distro/raspi-gpio
-
@cyperghost I'll try that though I'm pretty new to Linux so that would be a first time compiling anything, good way to learn!
This the most I could delete without breaking functionality. Is it difficult to add the reset button to just reboot?
Retroflag_Raspbian-Shutdown.sh
Danke schön!
-
@denisuu yes that is a stripped down version. Now use the if clause in line 28 and write your reboot command in. You can further strip down this if you want. Take care about the reset value I am not sure what it's default is. 0 or 1 just pretest with echo command.
-
I compiled raspi-gpio on OSMC and the script is working now!!! I wouldn't know how to further strip this down, it's a miracle I even got this far!
The onlything left to do is the reboot button.
When it's finished is it ok if I put them on Github? All credits to you ofcourse!
-
It was just as simple as putting sudo reboot on the line you said! It seems the button doesn't work every time, sometimes I have to press twice but good enough! Maybe it's just the case...
I put this here:
https://github.com/Denisuu/OSMC_NesPi-SuperPi_Safe-ShutdownI haven't linked it anywhere so if you have any objections let me know!
-
@denisuu said in Multi Switch Shutdown Script!:
I compiled raspi-gpio on OSMC and the script is working now!!! I wouldn't know how to further strip this down, it's a miracle I even got this far!
Nice job. This is IMHO the best solution to go
When it's finished is it ok if I put them on Github? All credits to you ofcourse!
Do as you like. I take a look to your git looks good.
Excuse me for my late reply I was on vacation and the internet connection was terrible bad so there was just room for some phone messaging and email. For goodness SMS worked very good ;)
-
I am just re-doing a new OSMC installation with Retropie embedded in it so I thought I would get a retroflag and finally put it in a case!
@denisuu
I followed your instructions on your git page. I have a question on step 1) You said I could run the command for OSMC as a one liner, but I got permission denied, I just had to run it as sudo in pieces; that worked until i got to the last command "make install". I get the following message:osmc:/usr/src/raspi-gpio$ make install gcc -DPACKAGE_NAME=\"raspi-gpio\" -DPACKAGE_TARNAME=\"raspi-gpio\" -DPACKAGE_VERSION=\"0.2\" -DPACKAGE_STRING=\"raspi-gpio\ 0.2\" -DPACKAGE_BUGREPORT=\"serge@raspberrypi.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"raspi-gpio\" -DVERSION=\"0.2\" -I. -g -O2 -MT raspi-gpio.o -MD -MP -MF .deps/raspi-gpio.Tpo -c -o raspi-gpio.o raspi-gpio.c /bin/bash: gcc: command not found Makefile:361: recipe for target 'raspi-gpio.o' failed make: *** [raspi-gpio.o] Error 127
Am I missing something?
-
I'm not sure, I tried it a couple of days ago and it was working.
Maybe you can try and compile it from here? https://github.com/RPi-Distro/raspi-gpio
-
Ok,
I reinstalled Retrosmc and that made it work. Works like a charm; if I had a way, id buy you both a drink.
-
@denisuu I lift your OSMC modification into first posting. Glad you compiled raspi-gpio to OSMC
-
Hi, noob here
I don't undestand 4 and 5 steps:- Now edit ES autostart with nano /opt/retropie/configs/all/autostart.sh and add script to like ....
- /home/pi/RetroPie/scripts/multi_switch.sh --nespi+ & but BEFORE the last line emulationstatio #auto
What I need if I want to make a power off option in retropie menu?
Thanks
-
@vivesladron What do you want to do?
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.