usb_set_state 1
elif [ "$BASENAME" == 'usb-disable' ]; then
usb_set_state 0
-elif [ "$BASENAME" == 'usb-status' ]; then
+elif [ "$BASENAME" == 'usb-status' ] || [ "$BASENAME" == 'usb-toggle' ]; then
status="`cat /sys/module/usbcore/parameters/authorized_default`"
# The "authorized_default" module parameter of usbcore controls the default
# 0 is unauthorized for all devices
# 1 is authorized for all devices
if [ "$status" == "0" ]; then
- echo "Hotplug disabled."
+ if [ "$BASENAME" == 'usb-toggle' ]; then
+ echo "Hotplug was disabled, enabling it..."
+ usb_set_state 1
+ else
+ echo "Hotplug disabled."
+ fi
elif [ "$status" == "1" ]; then
- echo "Hotplug enabled."
+ if [ "$BASENAME" == 'usb-toggle' ]; then
+ echo "Hotplug was enabled, disabling it..."
+ usb_set_state 0
+ else
+ echo "Hotplug enabled."
+ fi
elif [ "$status" == "-1" ]; then
- echo "Hotplug enabled except wireless"
+ if [ "$BASENAME" == 'usb-toggle' ]; then
+ echo "Hotplug was enabled, disabling it..."
+ usb_set_state 0
+ else
+ echo "Hotplug enabled except wireless"
+ fi
fi
fi