XMG (X11 Mouse Grabber) is a Linux/X11 tool for intercepting mouse button press events and triggering actions.
It's a way of making use of the extra mouse buttons when the manufacturer does not provide Linux drivers and/or tools for configuring button actions (which means 99.9% of the cases).
-
Install libxcb. In most distributions it's possible to install it through the package manager.
-
Download the latest release and place it under
/usr/local/bin
or other executable location. -
Create a configuration file.
-
Execute
xmg
passing as argument the relative or absolute path to the configuration file. For example:xmg ~/.config/xmg.toml
-
(optional) Create an autostart configuration. For KDE environments, this can be a simple script in
~/.config/autostart-scripts
.
Configuration files are written in TOML format. The following example describes all supported options:
version = 1
[[mappings]]
button = 8
command = '''
qdbus org.kde.kglobalaccel
/component/kwin invokeShortcut "ExposeAll"
'''
[[mappings]]
button = 9
command = '''
dbus-send
--type=method_call
--dest=org.mpris.MediaPlayer2.spotify
/org/mpris/MediaPlayer2
org.mpris.MediaPlayer2.Player.PlayPause
'''
You can find out the button numbers by using xinput
, from xorg-xinput
package:
xinput test-xi2 --root | grep -A 10 ButtonPress
The number after detail
is the button number.
You can check XMG is receiving mouse events correctly by looking at debug logs. To activate them, set the LogLevel
environment variable to debug
:
LogLevel=debug xmg config.toml
- Configurations per application
- Long press actions