The short of it is that I am trying to add a keybinding to my program that will edit the clipboard and then paste the changes to whatever window you have active. On Windows I think I can probably do it with message passing, but X doesn't use message passing like that, so in order to do this, I'm just using python-evdev to send a ctrl+v event to uinput. This works reasonably well when you just run it, but I need it to run on a keybinding, in this case super+v. The problem becomes that when you send the ctrl and v events to uinput, the super mask is still active, so instead of send ctrl+v to the window, it sends ctrl+super+v, which doesn't actually do anything. Here's minimal code to explain exactly what i'm talking about:
import evdev,time,keybinder,gtk
def callback():
with evdev.UInput() as uinput:
uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_LEFTCTRL, 1)
uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_V, 1)
uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_V, 0)
uinput.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_LEFTCTRL, 0)
uinput.syn()
keybinder.bind("<super>v",callback)
keybinder.bind("Escape",gtk.main_quit)
gtk.main()
If you release super quickly enough you can actually get it to work, but it's pretty fast and obviously not acceptable for an actual application. I've tried to release super but that raises a few problems; it's not very generic, it raises the problem of what to do afterwards (Leave it released? Press it again? What if they released within the time between you releasing and then pressing it again?), and, most importantly, it doesn't really seem to work.
Anyways, I guess the question is, is there any way around this? Perhaps a way to send keypress events that won't combine with the physical keyboard(unlikely)? If not, is there any better way to get it to paste generically on Linux?