Skip to content

Commit 0ca3cf3

Browse files
committed
add Debian package sources for resetting USB after resume
1 parent 2d5ae18 commit 0ca3cf3

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

uhk-usb-service/DEBIAN/control

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: uhk-usb-rebind
2+
Version: 1.0
3+
Section: utils
4+
Priority: optional
5+
Architecture: all
6+
Maintainer: Benedek Kupper <[email protected]>
7+
Description: Rebinds UHK USB devices on resume to fix scrolling issues
8+
This package provides a script and a systemd service that put both the host and the device
9+
into a known good state after resuming from suspend. This is a temporary workaround,
10+
until this patch is merged into the Linux kernel:
11+
https://lore.kernel.org/linux-input/[email protected]/T/#u

uhk-usb-service/DEBIAN/postinst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
systemctl enable uhk-usb-rebind.service
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=UHK USB reset after resume
3+
After=suspend.target
4+
5+
[Service]
6+
Type=oneshot
7+
ExecStart=/usr/local/bin/uhk-usb-rebind.sh
8+
9+
[Install]
10+
WantedBy=suspend.target
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
declare -a uhk_devices=(
4+
"37a8:0001"
5+
"37a8:0003"
6+
"37a8:0005"
7+
"37a8:0007"
8+
"37a8:0009"
9+
)
10+
11+
USB_DRIVER_PATH="/sys/bus/usb/drivers/usb"
12+
13+
for dev in /sys/bus/usb/devices/*; do
14+
if [[ -f "$dev/idVendor" && -f "$dev/idProduct" ]]; then
15+
VID=$(cat "$dev/idVendor")
16+
PID=$(cat "$dev/idProduct")
17+
MATCH="${VID}:${PID}"
18+
19+
for target in "${uhk_devices[@]}"; do
20+
if [[ "$MATCH" == "$target" ]]; then
21+
DEVNAME=$(basename "$dev")
22+
23+
if [[ -e "$USB_DRIVER_PATH/unbind" ]]; then
24+
echo "$DEVNAME" | sudo tee "$USB_DRIVER_PATH/unbind"
25+
sleep 1.5
26+
echo "$DEVNAME" | sudo tee "$USB_DRIVER_PATH/bind"
27+
echo "Rebound device: $dev"
28+
fi
29+
fi
30+
done
31+
fi
32+
done

0 commit comments

Comments
 (0)