0

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?

Community
  • 1
  • 1
Cestarian
  • 232
  • 4
  • 10
  • 2
    Rename your file to something other than `uinput.py` and try again. – Vincent Savard Feb 16 '16 at 19:53
  • Also delete any `uinput.pyc` – mechanical_meat Feb 16 '16 at 19:54
  • @VincentSavard Doh that is so elementary! That's what I get for not being used to imports (it's also been a while since I touched any code beyond bash scripts, in my defense). I rephrased the question to fit my current predicament after I got it compiling. Thanks for your help, and sorry for the mess. – Cestarian Feb 16 '16 at 20:22

1 Answers1

2

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.

whot
  • 290
  • 1
  • 3
  • I was hoping to create a third party macro program which would fool libinput into thinking that there were inputs coming from the keyboard by using uinput. But you're saying I can instead create a virtual keyboard device with uinput that libinput will be able to read? – Cestarian Feb 22 '16 at 00:22
  • yes, a keyboard created with uinput will look the same as a real keyboard to libinput – whot Feb 22 '16 at 08:21
  • Thanks, I'll try that. – Cestarian Feb 22 '16 at 10:26