0

Tl;dr:

Moving the mouse while rotating the scroll wheel prevents the scrolling from actually happening in most applications. imwheel helps, but how do I run it on startup or login so that it actually works?

In detail:

I have a Windows 10 host and an Ubuntu 20.04 guest. The guest was originally installed in VMware, but I exported it (via an OVF) to VirtualBox too, for testing. In VMware Player I am using the "not optimized for gaming" mouse setting.
I have two physical mouses attached. One is the normal mouse that controls the host OS ("Host-Mouse"). The other is passed through to the guest OS ("Guest-Mouse"). The following table shows the combinations of movement and wheeling of both mouses and what the guest OS is doing:
Default
Red means it doesn't work and it's a problem, orange means it doesn't work but it's acceptable (for me).
The problem does not occur in FireFox (so far it's the only exception I found), but in "Text Editor", "Settings", "Files" and - most problematic for me - "Qt Creator" the cursor moves but the window is not scrolled.
I found imwheel, which fixes the problem, but I cannot figure out the arcane rituals necessary to run it at startup or login such that it actually works.

Why is this so long?:

This was gonna be about the mouse wheel problem itself, but right at the end I found imwheel. I already wasted hours testing and writing all of this down, so while I cut it down, I don't want to let it all go to waste.

What I tried:

I've seen others with the same problem and no (good/applicable) solution:
https://communities.vmware.com/t5/VMware-Workstation-Pro/Mouse-scrolling-in-VM-guest-doesn-t-work-when-mouse-is-moving/td-p/2731610
Added those settings, no change.
https://communities.vmware.com/t5/Horizon-Desktops-and-Apps/Mouse-wheel-does-not-work/td-p/2835340
Was already on, disabled and re-enabled it, no change.
https://askubuntu.com/questions/1080542/mouse-scroll-doesnt-work-while-moving-pointer-on-vmware-workstation-with-ubuntu
Tried EN-US keyboard layout, no change.
Tried the commands suggested by Arwez, no change.
https://unix.stackexchange.com/questions/446314/scrolling-impossible-while-moving-mouse-fedora-28-vm-guest-on-win10/498564#498564
Tried xev | grep -n -e "ButtonPress" -e "ButtonRelease", I see activity from the mouse wheel while moving.
xinput showed "Virtual core XTEST pointer" (ID 4) and "Logitech M325" (ID 12) for both VMware and VirtualBox, and then some other slave pointers that differ between the two. I tried disabling each one individually with e.g. xinput disable 4:
Disabling "Virtual core XTEST pointer" errors out with "BadAccess".
In all other cases something was not working, but it never worked in the intended way.

Workaround:

scroll wheel not working when mouse is moving
Using "optimized for games" mouse in VMware and disabling mouse-integration in VirtualBox works, but it's not a great solution since that makes switching between guest and host extremely annoying.
VMware:
enter image description here
VirtualBox:
enter image description here

imwheel:

Taken from this answer: Inconsistent and erratic mouse wheel in Linux while moving the mouse pointer
Running imwheel while already in a console, either as root or as a normal user, fixes the issue.
But none of the ways I tried to have it run automatically work:

init.d:
I considered adding a file to /etc/init.d that simply runs imwheel, but I could not find a sensible explanation of how to create such a file or what the contents that I found in existing files mean (particularly parts of the comment header).

systemd:
Taken from this tutorial: https://linuxconfig.org/how-to-run-script-on-startup-on-ubuntu-20-04-focal-fossa-server-desktop
I created the file /etc/systemd/system/imwheel.service with the following content:

[Unit]
After=display-manager.service
[Service]
ExecStart=/usr/bin/imwheel > /home/user/Desktop/imwheel.txt 2>&1
[Install]
WantedBy=default.target

And ran these commands and rebooted:

chmod 664 /etc/systemd/system/imwheel.service 
systemctl daemon-reload
systemctl enable imwheel.service

The imwheel.txt file was not created.

crontab -e:
I added these two lines to crontab and rebooted:

@reboot /usr/bin/imwheel > /home/user/Desktop/imwheel.txt 2>&1
@reboot echo "a" > /home/user/Desktop/echo.txt

The two files are created, echo.txt contains "a", but imwheel.txt contains the following:

INFO: imwheel started (pid=741)
Could not open display, check shell DISPLAY variable, and export or setenv it!

This happens with both root and the normal user.

Startup Applications:
Taken from this answer: https://askubuntu.com/questions/101197/how-can-i-make-an-application-start-up-when-i-login/101200#101200
I hit the windows key, searched for "startup applications", clicked on the only result, added a new entry with the command /usr/bin/imwheel > /home/user/Desktop/imwheel.txt 2>&1.
The imwheel.txt file was not created.

1 Answer 1

0

Ok, this is actually not as easy as it should be. Creating a systemctl user unit is the right approach but you will need to find the right dependencies to wait for - imwheel will work only if the X display and session are ready. Here's the imwheel.service definition I am using in Manjaro 5.15 + KDE that works reliably to start imwheel once I log into my session:

[Unit]
Description=IMWheel
After=plasma-kwin_x11.service
PartOf=graphical-session.target
[Service]
Type=simple
Environment=XAUTHORITY=%h/.Xauthority
Environment=DISPLAY=:0
ExecStart=/usr/bin/imwheel -kill -d
ExecStop=/usr/bin/pkill imwheel
RemainAfterExit=yes
Restart=on-failure
Slice=session.slice
[Install]
WantedBy=graphical-session.target

In order to customize this script to your environment, run systemctl --user status and identify your window manager or something similar, look up its definition file which likely will be in /usr/lib/systemd/user and adapt the service definition above. Will most likely require you to change After=, Slice=, PartOf= and WantedBy= based on your environment.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .