Guest User

Untitled

a guest
May 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. This file contains one of three words: "on", "auto",
  2. or "suspend". You can write those words to the file
  3. to change the device's setting.
  4.  
  5. "on" means that the device should be resumed and
  6. autosuspend is not allowed. (Of course, system
  7. suspends are still allowed.)
  8.  
  9. "auto" is the normal state in which the kernel is
  10. allowed to autosuspend and autoresume the device.
  11.  
  12. "suspend" means that the device should remain
  13. suspended, and autoresume is not allowed. (But remote
  14. wakeup may still be allowed, since it is controlled
  15. separately by the power/wakeup attribute.)
  16.  
  17. cat /proc/bus/usb/devices
  18.  
  19. T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=1.5 MxCh= 0
  20. D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
  21. P: Vendor=046d ProdID=c50e Rev=25.10
  22. S: Manufacturer=Logitech
  23. S: Product=USB RECEIVER
  24. C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 70mA
  25. I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
  26. E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms
  27.  
  28. T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=1.5 MxCh= 0
  29. D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
  30. P: Vendor=046d ProdID=c50e Rev=25.10
  31. S: Manufacturer=Logitech
  32. S: Product=USB RECEIVER
  33. C: #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 70mA
  34. I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=
  35. E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms
  36.  
  37. echo -n "Bus-Rank" > /sys/bus/usb/drivers/usb/unbind
  38. echo -n "1-2" > /sys/bus/usb/drivers/usb/unbind (in our example)
  39.  
  40. echo -n "Bus-Rank" > /sys/bus/usb/drivers/usb/bind
  41. echo -n "1-2" > /sys/bus/usb/drivers/usb/bind (in our example)
  42.  
  43. #!/bin/bash
  44.  
  45. USBmouseProduct="USB RECEIVER"
  46. USBmouseManufacturer="Logitech"
  47.  
  48. signal=$1
  49.  
  50. nr3=$(awk '/Product='"$USBmouseProduct"'/ {print NR}' /proc/bus/usb/devices)
  51. nr3=$(expr $nr3 + 0)
  52. nr2=$(awk '/Manufacturer='"$USBmouseManufacturer"'/ {print NR}' /proc/bus/usb/devices)
  53. nr2=$(expr $nr2 + 0)
  54. nr1=$(expr $nr2 - 3)
  55. nr4=$(expr $nr3 + 1)
  56. nrdiff=$(expr $nr3 - $nr2)
  57.  
  58. [ $nr3 != 0 -a $nr2 != 0 -a $nrdiff = 1 ] && (
  59. usbmbus0=$(awk 'NR=='$nr1' {print $2}' /proc/bus/usb/devices | awk -F= '{print $2}')
  60. usbmbus=$(expr $usbmbus0 + 0)
  61. usbmdev=$(awk 'NR=='$nr1' {print $8}' /proc/bus/usb/devices)
  62. usbmrank=$(awk 'NR=='$nr1' {print $5}' /proc/bus/usb/devices | awk -F= '{print $2}')
  63. usbmrank=$(expr $usbmrank + 1)
  64. usbmbusrank="$usbmbus""-""$usbmrank"
  65. usbmpower=$(awk 'NR=='$nr4' {if ( $1=="C:" ) {print 0}; if ( $1=="C:*" ) {print 1}}' /proc/bus/usb/devices)
  66.  
  67. case $signal in
  68. off|0)
  69. [ $usbmpower = 1 ] && echo -n "$usbmbusrank" > /sys/bus/usb/drivers/usb/unbind
  70. ;;
  71. on|1)
  72. [ $usbmpower = 0 ] && echo -n "$usbmbusrank" > /sys/bus/usb/drivers/usb/bind
  73. ;;
  74. esac
  75. )
  76.  
  77. echo suspend | sudo tee /sys/bus/usb/devices/usb3/power/level
  78.  
  79. sudo lsusb -v|less
  80.  
  81. sudo lsusb -t|less
  82.  
  83. /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
  84. |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
  85. |__ Port 1: Dev 3, If 0, Class=hub, Driver=hub/3p, 480M
  86. |__ Port 1: Dev 6, If 0, Class=HID, Driver=usbhid, 1.5M
  87.  
  88. echo '2-1.1.1'|sudo tee /sys/bus/usb/drivers/usb/unbind
  89. sleep 1
  90. echo '2-1.1.1'|sudo tee /sys/bus/usb/drivers/usb/bind
Add Comment
Please, Sign In to add comment