Mapping KDE’s zoom to a mouse wheel

KDE’s kwin is the module that handles all window management, and one of the things that KDE can do is zoom in on the displayed graphics. This isn’t the same as KMag(nifier) which pops up a dedicated program where you can scroll around and change the zoom level; it’s a desktop-level control that zooms the whole desktop environment.

Typically, the functionality is bound to two different keyboard shortcuts – Meta (Win) + =, and Meta + - for zoom in and out respectively. Unfortunately, the shortcut handling code in KDE5 doesn’t seem to be able to handle mouse scroll wheel events (which are just button presses). There’s custom gesture controls in Custom Shortcuts, which is really neat, but nothing in there seems to handle mouse button 4 and 5 (scroll wheel events).

Enter xbindkeys, and the fact that KDE exposes pretty much everything over dbus. So long as xbindkeys is started, and configured, it’ll intercept defined events and trigger commands.

"qdbus org.kde.kglobalaccel /component/kwin invokeShortcut 'view_zoom_in'"
   Mod4+b:4
"qdbus org.kde.kglobalaccel /component/kwin invokeShortcut 'view_zoom_out'"
   Mod4+b:5

That’s all that’s needed to invoke the zoom in and out based on the mouse wheel being scrolled while the Meta key is held down.

Meta + wheel scroll to trigger zooming of the desktop environment

Tags: