aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-01-27 07:16:23 -0200
committerSilvio Rhatto <rhatto@riseup.net>2018-01-27 07:16:23 -0200
commit78fd7ea812a869dbf95d31db0dcaa0732348e840 (patch)
tree794f00b45b7c1e9ab3425f8e3915639dff3685f9
parent75836290121cae996621d68c8445ef575aa53490 (diff)
downloadhydra-78fd7ea812a869dbf95d31db0dcaa0732348e840.tar.gz
hydra-78fd7ea812a869dbf95d31db0dcaa0732348e840.tar.bz2
Adds hydractl usb-toggle
-rwxr-xr-xshare/hydractl/usb-disable23
l---------share/hydractl/usb-toggle1
2 files changed, 20 insertions, 4 deletions
diff --git a/share/hydractl/usb-disable b/share/hydractl/usb-disable
index d3684c7..8c7d4a3 100755
--- a/share/hydractl/usb-disable
+++ b/share/hydractl/usb-disable
@@ -34,7 +34,7 @@ if [ "$BASENAME" == 'usb-enable' ]; then
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
@@ -44,10 +44,25 @@ elif [ "$BASENAME" == 'usb-status' ]; then
# 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
diff --git a/share/hydractl/usb-toggle b/share/hydractl/usb-toggle
new file mode 120000
index 0000000..f54f446
--- /dev/null
+++ b/share/hydractl/usb-toggle
@@ -0,0 +1 @@
+usb-disable \ No newline at end of file