
If like me you've had enough of mouse scroll skipping in X11-based Desktop Linux Guest VMs, after years of searching I finally have the solution.
The Problem
In all Linux distros with any X11-based desktop environment that I've ever used in VirtualBox as guest OSes I've experienced the same infuriating issue: if I were to scroll the mouse wheel slowly (especially when scrolling up-down-up-down...) — the inputs would randomly get "eaten" for some reason. This led to them not being registered, which was extremely annoying, because I had no clue why this was the case only with the Linux guests, and never with Windows XP/7/10 ones.
The Cause
Most modern Linux environments are optimized for High-Resolution scrolling (like Apple’s Magic Mouse or smooth trackpads). And this doesn't play nice with virtualization, at least when run with VirtualBox:
- The mouse sends a scroll wheel event
- VirtualBox tries to be "helpful" and converts that click into a high-resolution coordinate (like 0.5 "units")
- The Linux Guest OS driver
libinputreceives that freaking 0.5 instead of a full 1.0 "click" - The toolkit (GTK or Qt) has a defined Scroll Step. In many configurations, that step is 1.0
- If you scroll slowly, you send 0.5... then a pause. Because the "accumulator" in the software often resets or doesn't persist across certain timing intervals in a VM, that 0.5 never reaches the 1.0 required to actually move the scroll bar. It is effectively "rounded down" to zero at that point, and your scroll input is lost!
The Solution
The ancient imwheel.
The freaking fossilized piece of software that dates to 1997–1999 when mice were luxury items, and the X Window System (X11) had no built-in way to understand a scroll wheel. It just saw "button presses" and didn't know what to do with them. For perspective: Windows 98 was the cutting-edge operating system of the time.
Yeah.
Here's a Bash script to install and make it load at startup, which should work out of the box for systems which use apt as a package manager.
- Save this as
setup_imwheel.shin your home directory either using a GUI text editor or even just pasting into a nano session:nano setup_imwheel.sh— paste, CTRL+x, y, Enter. - Make it executable:
chmod +x setup_imwheel.sh - Run it:
./setup_imwheel.sh
How it works: imwheel sits at the top of the X11 windowing system and intercepts input events. It suppresses these incomplete fractional scroll wheel events and instead injects its own "Button 4" and "Button 5" pulses back into the system, resulting in consistent scrolling behavior.
Full script below. I give no guarantees whatsoever. It works great for me, and you can take it or leave it.
#!/bin/bash
# ======================================================
# Script: setup_imwheel.sh
# Purpose: Fix mouse wheel skipping in VirtualBox
# Target: Linux Mint / Ubuntu / Debian (X11) etc...
# ======================================================
set -e
echo "Installing imwheel"
sudo apt update && sudo apt install -y imwheel
# Dynamically find the path to the binary to ensure the autostart works
# regardless of whether it's in /usr/bin or /usr/local/bin
IMWHEEL_PATH=$(which imwheel)
echo "Configuring ~/.imwheelrc"
# Creating the config for vertical scrolling only
cat << 'EOF' > ~/.imwheelrc
# Config for VirtualBox Mouse Skipping
".*"
None, Up, Button4, 2
None, Down, Button5, 2
EOF
echo "Setting up Autostart"
mkdir -p ~/.config/autostart
# Creating the desktop entry with a 5s delay to ensure X11 is ready
cat << EOF > ~/.config/autostart/imwheel.desktop
[Desktop Entry]
Type=Application
Exec=sh -c "sleep 5 && $IMWHEEL_PATH -k -b '4 5'"
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Mouse Wheel Fix
Comment=Fixes VirtualBox scrolling skipping
EOF
# Launch immediately for the current session
$IMWHEEL_PATH -k -b "4 5"
echo "Setup complete! imwheel is active and configured for autostart."
The script can be run several times without problems, it will simply overwrite the ~/.imwheelrc and the ~/.config/autostart/imwheel.desktop config files each time.
That's it. No more mousewheel skipping issues for X11-based ditros as VirtualBox guests.
As for Wayland — I downloaded and tested Zorin OS 18 in both modes: "Zorin Desktop" (Wayland) and "Zorin Desktop on Xorg" (X11). I had no issues in with Wayland eating mouse wheel inputs! But sure enough — in the Xorg session the mouse wheel began skipping again. So I guess Wayland plays well with mouse wheel scrolling in VirtualBox, which is great news. Regardless, don't try using imwheel in Wayland, because it's strictly X11-specific! It simply won't work since Wayland is much more secure and wouldn't let imwheel to inject input events like X11 does.
It's especially ironic that I discovered imwheel at this particular time, since I'm working on a giant post about another dinosaur from the world of software — Tcl/Tk. A programming language that silently powers Fortune-500 companies, but remains hidden in plain sight, so almost no one is aware of its existence. What are the odds!
OMG, freaking finally!