-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse
More file actions
executable file
·46 lines (39 loc) · 795 Bytes
/
Copy pathmouse
File metadata and controls
executable file
·46 lines (39 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
function mouse_usb_port() {
for port in /sys/bus/usb/devices/?-?.?; do
for device in ${port}/?-?.?:?.?; do
read class < ${device}/bInterfaceClass
read subclass < ${device}/bInterfaceSubClass
read protocol < ${device}/bInterfaceProtocol
if [[ $class == 03 && $subclass == 01 && $protocol == 02 ]]; then
echo $port
return
fi
done
done
}
dir="$(mouse_usb_port)/power"
control="${dir}/control"
auto="${dir}/autosuspend"
case "$1" in
"auto")
echo on > $control
echo 300 > $auto
echo "auto" > $control
;;
"on")
echo "on" > $control
;;
"off")
echo 0 > $auto
echo auto > $control
sleep 0.01
echo 300 > $auto
;;
"fix_perm")
chown :usb $control $auto
chmod g+w $control $auto
;;
*)
echo "Usage: mouse [auto|on|off]"
esac