(日本語の本文は続きにあります)
For English readers,
This script is written for Volumio on Raspberry pi.
It enables one push switch (momentary on) to control two functions: shutdown and play/pause toggle.
When you press the switch over 5 s, the system shutdowns. An LED turns on informing you that the system enters the shutdown process and you can release the switch.
When you press for a moment (1 s or so), mpd starts/pauses the music -- toggle.
Watch the video below.
Install a push switch between Pins 15 and 17 of the GPIO port.
Install an LED between Pins 20 and 22. Pin 20 is for the cathode (K). No register is required (but a 50 - 200 ohm register in series is prefered :-) )
See the photo on this
page.
The script may be named as you like, and the permission is 755. Run it as daemon by adding the following line at the end of /etc/rc.local (just before 'exit 0' line).
When the script name is 'daemon.sh' and it is located at /home/volumio,
su -c /home/volumio/daemon.sh &