I finally got around implementing a shutdown button. It is based on the
script gib8 created but I modified it slightly. The hardware is a bit
different too. I use a delayed button; you have to press and hold it for
about 2 seconds before it kicks in. 

The hardware consists of just a few components: 

15653

1565215651



As mentioned, I slightly modified gib8’s script and called it
*csos-shutdown*. It is located in */usr/sbin* and contains the
following:


Code:
--------------------
    
  #!/bin/bash
  
  sudo echo in > /sys/class/gpio/gpio91/direction
  sudo echo out > /sys/class/gpio/gpio200/direction
  sudo echo 1 > /sys/class/gpio/gpio200/value
  
  while [ true ]; do
        i=`cat /sys/class/gpio/gpio91/value`
        if [ $i -eq 1 ] 
        then
                        sudo echo 0 > /sys/class/gpio/gpio200/value
                        sleep 0.5
                        sudo echo 1 > /sys/class/gpio/gpio200/value
                        sleep 0.5
                        sudo echo 0 > /sys/class/gpio/gpio200/value
                        sleep 0.5
                        sudo echo 1 > /sys/class/gpio/gpio200/value
                        sleep 0.5
                        sudo echo 0 > /sys/class/gpio/gpio200/value
                        sleep 0.5
                        sudo echo 1 > /sys/class/gpio/gpio200/value
                        sleep 0.5
                        sudo echo 0 > /sys/class/gpio/gpio200/value
                        sudo shutdown -h now
  break
        fi
        sleep 1
  done
  
--------------------


This script needs to be executable, so run the command *chmod 777
csos-shutdown*

Next, create a service file called *shutdown.service* located in *
/etc/systemd/system*
The shutdown.service file contains the following:


Code:
--------------------
    
  [Unit]
  Description=Shutdown Switch
  
  [Service]
  ExecStart=/usr/sbin/csos-shutdown
  Type=idle
  
  [Install]
  WantedBy=multi-user.target
  
--------------------


Then enable the service: *systemctl enable shutdown.service* and reboot
the system.

How does it work: press and hold the button (about two seconds) until
the LED starts to blink. Allow about 30 seconds (to be sure) to let the
WB shutdown safely before removing the power.


+-------------------------------------------------------------------+
|Filename: Shutdown_Switch.jpg                                      |
|Download: http://forums.slimdevices.com/attachment.php?attachmentid=15653|
+-------------------------------------------------------------------+


1 x SB3, 1 x SB Boom, 1 x SB Radio and 2 x SB Touch - all wireless
1 x Wandboard Dual behind the bedroom ceiling
1 x Wandboard Dual for 'msqueeze' (http://www.msqueeze.co.nf/index.html)
project
ReadyNAS NVX running LMS 7.7.3. w iTunes plugin
iPeng 7 on iPhone.
SqueezePad & iPeng 7 on iPad.
http://www.last.fm/user/phibon
------------------------------------------------------------------------
Pascal Hibon's Profile: http://forums.slimdevices.com/member.php?userid=7969
View this thread: http://forums.slimdevices.com/showthread.php?t=99395

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to