I would like to ask you if it is possible to listen for every new selection in an asynchronous way?
I know that there is a " gtk_clipboard_wait_for_contents ()" function but I have to explicitly invoke it every time I want to check if something is selected. But is there a way to “register” my app as an listener for this event?
Is the “owner-change" signal a thing that I look for?
I want to create an app which listens for selection and does something with the selected text. The application has to work in the background and show some notification when selection occurs.
What about using extend-selection signal ?
It seems you want to create a clipboard manager. That’s not a great plan, I’m sorry to say.
You cannot listen to events happening on other applications, and there’s no “selection event” at the windowing system level. The clipboard functionality itself doesn’t work that way; you’re supposed to ask for the clipboard’s contents whenever you want to paste them.
In theory, you could use the
GtkClibpboard::owner-change signal, and every time the signal fires, you retrieve the contents of the clipboard; this functionality is only ever possible on X11, though, because having random clients being able to get notifications about clipboard state from other applications isn’t really good from the perspective of a secure environment.
In practice, if you want to create a clipboard manager, you have to do so within the context of the compositor/display server.
Thank you @ebassi . It clarifies everything. Regards
I think it works only in the context of a one particular application. I wanted to have an app which listens for other applications. @ebassi solved the issue with his post: https://discourse.gnome.org/t/is-it-possible-to-listen-for-selection-events/4997/3
Yes I thought your were talking about application specific configuration.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.