Mouse grab for vmware

written by Tomas M. 5 years ago

I noticed that many other Linux distributions can detect if they are running in vmware virtual box and automatically configure X to grab / ungrab the mouse cursor. You probably know what I am talking about if you ever tried Slax in vmware, you had to press Ctrl+Alt to release mouse cursor from the guest, and you had to click inside the vmware window to grab the cursor in the virtual machine again. That may be annoying. I thought that vmware tools are needed for automatic grab/ungrab to work, but today I learned it can work out of the box without vmware tools at all.

Xorg has vmmouse driver for long time. It even provides /usr/bin/vmmouse_detect binary, which is a tiny program which detects if the moduse is to be handled by the vmmouse driver. Yet the package xf86-input-vmmouse contains only HAL rules to autodetect vmware mouse, and since HAL is no longer included in Slackware since version 14, X falls back to evdev driver or something like that. The following can be seen in Xorg.log.0:

Hotplugging is on, devices using drivers 'kbd', 'mouse' or 'vmmouse' will be disabled


So how to make Xorg use the vmmouse driver? The following udev rule makes the trick, and will be included in Slax:

ACTION=="add|change", ENV{ID_INPUT_MOUSE}=="?*", ATTRS{description}=="i8042 AUX port", KERNEL=="event[0-9]*", PROGRAM="/usr/bin/vmmouse_detect", ENV{ID_INPUT.tags}="vmmouse"


This is in debian for very long time, but didn't make its way to the official xorg input driver nor to Slackware. I'm going to submit this upstream as well since this tiny change makes a big difference for vmware users.

Tomas M.

(c) 2018, Tomas M; rss