It's more of a question in "where to start?" category.
I need to make an app that can read currently selected text in Linux. It will only be used in KDE with KWin and X11 (Kubuntu, if that matters).
For example this is expected UX: I'm selecting text in Kate (or any other app) -> press some global shortcut -> either app starts or already running in background and reads that selected text from Kate and does something with it (saves to file, for example). And it should be able to read selection from any application (browsers, GTK apps, Qt apps, etc).
Is it even possible? Where should I start? What subsystem should have this info of "currently focused window" and "selected text in that window"? How can this be achieved? I would very much appreciate any guidance or insight, because I'm completely new to linux/KDE app development. Maybe there's an open-source app that does this so I can try and learn from sources? No requirements on lang and framework but Qt/C++ is preferable.
Thank you