Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shutdown Raspberry PI 3 when phone is being disconnecting
#1
<r>1. Open <B><s></s>openauto.rules<e></e></B> file
<CODE><s>
Code:
</s>$ sudo nano /etc/udev/rules.d/openauto.rules<e>
</e></CODE>

2. Add below lines at the end of the <B><s></s>openauto.rules<e></e></B> file
<CODE><s>
Code:
</s>SUBSYSTEM=="usb", ACTION=="add", ENV{ID_VENDOR_ID}=="18d1", ENV{ID_MODEL_ID}=="2d00", RUN+="/bin/sh -c '/sbin/shutdown -c && echo 0 > /sys/class/backlight/rpi_backlight/bl_power'"<e>
</e></CODE>

<CODE><s>
Code:
</s>SUBSYSTEM=="usb", ACTION=="add", ENV{ID_VENDOR_ID}=="18d1", ENV{ID_MODEL_ID}=="2d01", RUN+="/bin/sh -c '/sbin/shutdown -c && echo 0 > /sys/class/backlight/rpi_backlight/bl_power'"
<e>
</e></CODE>
<CODE><s>
Code:
</s>SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_VENDOR_ID}=="18d1", ENV{ID_MODEL_ID}=="2d00", RUN+="/bin/sh -c '/sbin/shutdown --poweroff 1 && echo 1 > /sys/class/backlight/rpi_backlight/bl_power'"<e>
</e></CODE>

<CODE><s>
Code:
</s>SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_VENDOR_ID}=="18d1", ENV{ID_MODEL_ID}=="2d01", RUN+="/bin/sh -c '/sbin/shutdown --poweroff 1 && echo 1 > /sys/class/backlight/rpi_backlight/bl_power'"<e>
</e></CODE>

Above script will do:<br/>
<br/>
1. Turn off the screen and schedule shutdown delayed for 1 minute when phone is being disconnecting<br/>
2. Turn on the screen and cancel shutdown when phone is being connecting<br/>
You can adjust 1 minute delay for your needs.</r>
Reply
#2
This nice piece of code do not seem to work on OAP 3.3.2b2 - It works fine on 3.3.1

The "log" from Raspbian states my phone has changed idVendor and idProduct to something else ((VID) 04e8 and (PID) 6860 and the naming has changed(?)
When USB is disconnected it just logs
"USB disconnect, device number XX" (where xx is a number that seems to raise with two for every reboot of the pi)
Reply
#3
In the OAP 3.3.2 b2 we have introduced shutdown and reboot buttons in Exit menu. In our opinion these seems to be better solution.
Reply
#4
Oki - thanks for fast reply
Reply
#5
New topic which should be interested for you
https://bluewavestudio.io/community/show...29#pid6129
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)