Skip to content
Advertisement

Creating Macros With Python interfacing with Libinput

I’m running Fedora 22; and I’m trying to create a very simple keyboard macro script with uinput that will work across display servers (and in console).

Following this post I figured out how to do this successfully in console and with evdev;

However I also want to be able to do this through libinput (for wayland, mir and X11); does anoyone know how that can be done?

Advertisement

Answer

This question doesn’t quite make sense in its current form, you’re confusing two different layers of the stack.

libinput is a library to handle events coming from kernel evdev devices. It does things like two-finger scrolling, touchpad gestures, mouse wheel emulation, etc. For keyboards, it pretty much just forwards whatever the kernel gives it (keyboard layouts are handled by the compositor and the client).

uninput is a kernel interface to create virtual devices that then show up as kernel evdev device nodes. libinput does not care whether a device is a physical device or a virtual uinput device (in fact, libinput’s test suite uses uinput devices heavily).

So a device created by uinput sits below libinput, any keyboard device that you create with uinput will show up as keyboard in a compositor using libinput. Thus any key event will be forwarded just as from a normal keyboard.

Now, you could try to add macro support to libinput directly, but that’s a lot harder to do and has virtually no chance of getting upstream. For a local use-case, a uinput-based solution should be sufficient.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement