Score:2

Ubuntu 20.04: Scroll wheel doesn't work for wireless mouse after system wakes up or when first plugged-in

in flag

I have a new Lenovo ThinkPad E15 that came with Windows 10 installed. I added Ubuntu 20.04 as an option (dual-boot).

Whenever the laptop sleeps (goes into a "suspend" state) and then later I wake it up, the Logitech wireless mouse scroll wheel doesn't work. ("Logitech MK270 Wireless Keyboard and Mouse Combo", but the only thing that doesn't work is the scroll wheel.)

I then unplug its USB-A dongle and replug it (I often need to do this multiple times), and then the mouse wheel works again.

I don't want to need to touch the USB plug at all. It should just always work. How can I fix this?

P.S. My question is very similar to Ubuntu 20.04: Scroll doesn't work for wireless mouse after system wakes up from suspended state, which has no answer yet.

P.P.S. I've confirmed that the USB switch in my setup is not related to the problem. The problem happens even when the tiny Logitech USB dongle is plugged directly into the laptop.

Ryan avatar
in flag
See also https://unix.stackexchange.com/questions/309247/linux-mouse-freezes-after-suspend. `sudo modprobe -r hid_logitech_dj && sudo modprobe -r usbhid && sudo modprobe hid_logitech_dj && sudo modprobe usbhid` disconnected and reconnected the USB mouse, but its wheel still doesn't work (unless I physically unplug and replug).
Ryan avatar
in flag
I also tried `sudo modprobe -r hid_logitech_dj && sudo modprobe -r logitech-djreceiver && sudo modprobe -r logitech-hidpp-device && sudo modprobe -r usbhid && sudo modprobe hid_logitech_dj && sudo modprobe usbhid && sudo modprobe logitech-djreceiver && sudo modprobe logitech-hidpp-device` but got an error `FATAL: Module logitech-djreceiver not found.`
Rho avatar
cn flag
Rho
Hi @Ryan: try connecting your commands with ";" instead of "&&" and check again (this will continue executing the orders even if you get an error from one of them). Regarding the output you posted, It seems like you don´t have the logitech-djreceiver installed, so I would try to go from there. Try a fresh install and then run the modprobe sequence. Hope it helps. Cheers.
emk2203 avatar
in flag
I cannot say with certainty if it fixes *your* problem, but I have a very similar one and just wanted to post a question myself. What I found so far for me may help you: `modprobe` doesn't help since the modules are not loaded. What helps is a reset of the usb bus. You can look for the USB ID of the device with `lsusb`. Install `usbutils` and issue `usbreset <USB ID>`. After this, the device should be recognized again without unplugging and replugging. A systemctl service similar to this answer should automate it: https://unix.stackexchange.com/a/227293/140914
Score:2
in flag

modprobe doesn't help here, the best chance is to reset the USB bus for this malfunctioning or missing device.

Look for the USB ID in the form of VID:PID of the device with lsusb. Install usbutils and issue usbreset VID:PID. After this, the device should be functioning again without unplugging and replugging. The bus reset is not exactly equal, but should be close enough.

To automate this action, make a systemctl service for it:

sudo vim /etc/systemd/system/[email protected]

Paste in these lines, and save the file:

[Unit]
Description="Reset a USB device after system resume"
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service]
Type=oneshot
ExecStart=/usr/bin/usbreset %i

[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

Recall the VID:PID value you got from lsusb.

For example, maybe it was 0bda:5411.

Enable/start the service by running a command like: sudo systemctl start reset-usb-upon-wake@VID:PID.service, such as sudo systemctl start reset-usb-upon-wake@0bda:5411.service.

This way, even if you have multiple devices that need this kind of service, they can all use this single service file.

Ryan avatar
in flag
Thanks for this answer. I'm trying it now and running into some problems. I will edit your answer above with what I think might work. And I'll come back here when I learn more.
Ryan avatar
in flag
I don't think I have this working. When I woke my computer from hibernation this morning, the scroll wheel didn't work. Does that mean I need more service files? Is there a way to make this work upon hibernation waking and first boot, too? Thanks! :-)
emk2203 avatar
in flag
First, look into the journal of systemd to see if everything was setup correctly: Boot the PC, go to sleep, resume and afterwards use `journalctl -b` to see everything since last boot. Look if your service ran after the resume. If it did, chances are that the usb reset method is unfortunately not sufficient in your case. If usb reset doesn't work, there's little to be done with software alone, I'm afraid.
emk2203 avatar
in flag
Switching the mouse off and on might be the best solution if software attempts fail.
Ryan avatar
in flag
I will try modifying based on https://unix.stackexchange.com/a/492497/48973
Ryan avatar
in flag
So far, I'm pretty sure that running `sudo systemctl start reset-usb-upon-wake@046d:c534.service` has worked every time, but afterwards it weirdly continually presses `Enter` (seemingly) in the terminal, causing the terminal to scroll endlessly until I type a new command. So I'd like to fix that, and also I still haven't gotten it to run automatically upon waking. I'll edit the answer above to show what I've tried.
Ryan avatar
in flag
In the log, I do see this, which *implies* that it worked: `Jan 11 09:05:22 ThinkPad-E15-Gen-2 systemd[1]: Starting "Reset a USB device after system resume"... Jan 11 09:05:22 ThinkPad-E15-Gen-2 kernel: usb 3-5.3: reset full-speed USB device number 16 using xhci_hcd Jan 11 09:05:22 ThinkPad-E15-Gen-2 usbreset[12310]: Resetting USB Receiver ... ok Jan 11 09:05:22 ThinkPad-E15-Gen-2 systemd[1]: reset-usb-upon-wake@046d:c534.service: Succeeded. Jan 11 09:05:22 ThinkPad-E15-Gen-2 systemd[1]: Finished "Reset a USB device after system resume". `
Ryan avatar
in flag
...but the mouse scroll wheel didn't *actually* work until I opened the terminal and manually ran that service. Any ideas? Thanks.
Ryan avatar
in flag
I awarded a bunch of points even though I still don't know how to fix my problem (because I really appreciated your continued effort). :-)
emk2203 avatar
in flag
Sorry for being absent for a while. It looks like there is some quirk with your hardware/software and it's *supposed* to function, but in reality, things are different. You could try a second reset via the service, maybe with a 1 second pause in between, and hope this helps, or maybe try a different kernel to see if the driver got some updates and it works with a newer version. You can try maybe with a live USB of the development 22.04. It has kernel 5.15, a LTS version, with a lot of improvements. If this works, maybe use kernel 5.15 in your 20.04. Thanks for the points!
Ryan avatar
in flag
If you have a moment, I've still been fighting this problem for more than a year. I've now asked it as a separate question: https://askubuntu.com/q/1454673/48214 Thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.