[Discuss] USB controls?
Patrick
Nixniq-sneaking at sneakEmail.com
Wed Mar 18 23:58:14 PDT 2015
Does anyone know if it's possible to cut power to USB devices
from software? I suspect it is, because the `eject' option in
Thunar [a file manager] not only unmounts external drives, but
seems to turn them off as well.
I just don't know how this is done. Any thoughts?
I'm thinking of running my wireless bridge off a USB connection
[it runs on 5v 1a, USB current, so no problem there], and have the
system test its connection periodically. Something like this;
#!/bin/sh
while :
do
ping -c 1 [arbitrary domain] \
&& online=1 \
|| online=0
if [ $online = 0 ]
then
ping -c 1 [arbitrary domain] \
&& online=1 \
|| online=0
# Try again, in case it as a one-time error.
while [ $online = 0 ]
do
[cut power to external USB device[s]]
sleep 12
[restore power to external USB device[s]]
sleep 123
#
# Give the bridge time to reboot / re-establish
# its connection.
# Test connection.
ping -c 1 [arbitrary domain] \
&& online=1 \
|| online=0
done
else
sleep 2222
fi
done
# End.
Thanks,
Patrick.
--
For every action, there is an equal and opposite criticism.
-- Harrison
More information about the Discuss
mailing list