You are not logged in.

#1 2018-08-29 15:59:12

rasputin
Member
Registered: 2018-07-23
Posts: 14
Website

[SOLVED] Send one X11 event to two applications

I've had this idea for some functionality I want to add to sent. It's a stupidly simple program for a presentation.

Basically, I want to have a script/program launch two different instances of sent and display different things on each.  The idea behind this being that you could have your main presentation on the projector, while having notes on your computer for you to look at.  This requires a lot and I think I've got the rest of it figured out.  But I still can't get this part figured out.  Is there a way to send one keyboard press to two applications in X through a script/program?  There has to be, But I'm not finding any documentation.

Last edited by rasputin (2018-08-31 21:02:01)


Russia's greatest love macine
===============================
PGP Fingerprint: 55A0 40FD A46B DADB
gitlab

Offline

#2 2018-08-29 16:49:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,451
Website

Re: [SOLVED] Send one X11 event to two applications

Absolutely.  You can do this with xdotool from a script, or use XSendEvent if you are writing your own program (e.g., in C using Xlib).

The problem you may face is how to get that script/program to send those events.  Presumably one of your "sent" windows will have focus and they'll receive the key events.  So without modifying the code of "sent" you'd not be able to know when to send the event to the other window.

One alternative is to keep focus on your scripts terminal window - but that may be impractical (so you'd have one CLI control interface to two graphical "sent" windows").  Another option would be to write some code that would do a global keyboard grab (XGrabKeyboard) and then dispatch events via XSendEvent to both of the "Sent" windows (you could get their window ids via a call to XQueryTree).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-08-31 21:04:05

rasputin
Member
Registered: 2018-07-23
Posts: 14
Website

Re: [SOLVED] Send one X11 event to two applications

Thanks for the info!!  I'm going to work out a bash script to do it, but I'll probably write an actual patch for it later on.


Russia's greatest love macine
===============================
PGP Fingerprint: 55A0 40FD A46B DADB
gitlab

Offline

Board footer

Powered by FluxBB