did it!
new install of moOde
sudo apt-get update
sudo apt upgrade
sudo apt autoremove
sudo apt install python3-gpiozero
sudo nano shutdown-press-simple.py
sudo chmod a+x shutdown-press-simple.py
sudo echo '~pi/shutdown-press-simple.py &'
sudo nano /etc/rc.local -> control the entry is before exit 0
done did use the shutdown&hold script but did not change the name.
pi@moode:~ $ ls -l /home/pi
total 8
-rwxr-xr-x 1 root root 1516 Dec 17 10:47 piano.sh
-rwxr-xr-x 1 root root 117 Jan 27 08:59 shutdown-press-simple.py
pi@moode:~ $ cat /home/pi/shutdown-press-simple.py
#!/usr/bin/env python3
from gpiozero import Button
from signal import pause
import os, sys
offGPIO = int(sys.argv[1]) if len(sys.argv) >= 2 else 26
holdTime = int(sys.argv[2]) if len(sys.argv) >= 3 else 6
# the function called to shut down the RPI
def shutdown():
os.system("sudo poweroff")
btn = Button(offGPIO, hold_time=holdTime)
btn.when_held = shutdown
pause() # handle the button presses in the background
pi@moode:~ $ cat /etc/rc.local
#!/bin/sh -e
SQLDB=/var/local/www/db/moode-sqlite3.db
# Unblock WiFi
/usr/sbin/rfkill unblock wifi > /dev/null 2>&1
# Set cpu govenor
CPU_GOV=$(sqlite3 $SQLDB "select value from cfg_system where param='cpugov'")
echo "$CPU_GOV" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# USB storage auto-mounter
/usr/bin/udisks-glue --config=/etc/udisks-glue.conf > /dev/null 2>&1
#/usr/bin/devmon --exec-on-drive "/var/www/command/util.sh smb_add %d %f" --exec-on-remove "/var/www/command/util.sh smb_remove %f" --always-exec --no-gui > /dev/null 2>&1 &
# Work around for Katana driver load failure on Pi-4B
AUDIO_DEVICE=$(sqlite3 $SQLDB "select value from cfg_system where param='i2sdevice'")
PI_REVNUM_SEGMENT=$(awk '{if ($1=="Revision") print substr($3,3,3)}' /proc/cpuinfo)
if [ "$AUDIO_DEVICE" = "Allo Katana DAC" ] && [ $PI_REVNUM_SEGMENT = "311" ]; then
rmmod snd_soc_allo_katana_codec
rmmod snd_soc_audio_graph_card
modprobe snd_soc_audio_graph_card
modprobe snd_soc_allo_katana_codec
echo `date +'%Y%m%d %H%M%S'` "rc.local ran Katana|Pi-4B driver reload" > /home/pi/katana.log
fi
# moOde startup and job processor daemon
/var/www/command/worker.php > /dev/null 2>&1
/home/pi/shutdown-press-simple.py &
exit 0
pi@moode:~ $ /usr/bin/env python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
pi@moode:~ $ which python3
/usr/bin/python3
pi@moode:~ $ uname -a
Linux moode 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l GNU/Linux
resources:
https://www.hifiberry.com/docs/hardware/...ry-boards/
https://webofthings.org/wp-content/uploa...i-gpio.png
https://github.com/TonyLHansen/raspberry...ff-switch/
https://gpiozero.readthedocs.io/en/stabl...lling.html
& thanks to the moOde team / forum.
new install of moOde
sudo apt-get update
sudo apt upgrade
sudo apt autoremove
sudo apt install python3-gpiozero
sudo nano shutdown-press-simple.py
sudo chmod a+x shutdown-press-simple.py
sudo echo '~pi/shutdown-press-simple.py &'
sudo nano /etc/rc.local -> control the entry is before exit 0
done did use the shutdown&hold script but did not change the name.
pi@moode:~ $ ls -l /home/pi
total 8
-rwxr-xr-x 1 root root 1516 Dec 17 10:47 piano.sh
-rwxr-xr-x 1 root root 117 Jan 27 08:59 shutdown-press-simple.py
pi@moode:~ $ cat /home/pi/shutdown-press-simple.py
#!/usr/bin/env python3
from gpiozero import Button
from signal import pause
import os, sys
offGPIO = int(sys.argv[1]) if len(sys.argv) >= 2 else 26
holdTime = int(sys.argv[2]) if len(sys.argv) >= 3 else 6
# the function called to shut down the RPI
def shutdown():
os.system("sudo poweroff")
btn = Button(offGPIO, hold_time=holdTime)
btn.when_held = shutdown
pause() # handle the button presses in the background
pi@moode:~ $ cat /etc/rc.local
#!/bin/sh -e
SQLDB=/var/local/www/db/moode-sqlite3.db
# Unblock WiFi
/usr/sbin/rfkill unblock wifi > /dev/null 2>&1
# Set cpu govenor
CPU_GOV=$(sqlite3 $SQLDB "select value from cfg_system where param='cpugov'")
echo "$CPU_GOV" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# USB storage auto-mounter
/usr/bin/udisks-glue --config=/etc/udisks-glue.conf > /dev/null 2>&1
#/usr/bin/devmon --exec-on-drive "/var/www/command/util.sh smb_add %d %f" --exec-on-remove "/var/www/command/util.sh smb_remove %f" --always-exec --no-gui > /dev/null 2>&1 &
# Work around for Katana driver load failure on Pi-4B
AUDIO_DEVICE=$(sqlite3 $SQLDB "select value from cfg_system where param='i2sdevice'")
PI_REVNUM_SEGMENT=$(awk '{if ($1=="Revision") print substr($3,3,3)}' /proc/cpuinfo)
if [ "$AUDIO_DEVICE" = "Allo Katana DAC" ] && [ $PI_REVNUM_SEGMENT = "311" ]; then
rmmod snd_soc_allo_katana_codec
rmmod snd_soc_audio_graph_card
modprobe snd_soc_audio_graph_card
modprobe snd_soc_allo_katana_codec
echo `date +'%Y%m%d %H%M%S'` "rc.local ran Katana|Pi-4B driver reload" > /home/pi/katana.log
fi
# moOde startup and job processor daemon
/var/www/command/worker.php > /dev/null 2>&1
/home/pi/shutdown-press-simple.py &
exit 0
pi@moode:~ $ /usr/bin/env python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
pi@moode:~ $ which python3
/usr/bin/python3
pi@moode:~ $ uname -a
Linux moode 5.10.63-v7+ #1496 SMP Wed Dec 1 15:58:11 GMT 2021 armv7l GNU/Linux
resources:
https://www.hifiberry.com/docs/hardware/...ry-boards/
https://webofthings.org/wp-content/uploa...i-gpio.png
https://github.com/TonyLHansen/raspberry...ff-switch/
https://gpiozero.readthedocs.io/en/stabl...lling.html
& thanks to the moOde team / forum.