Skip to content

Fix polling/watching clipboard on Linux Wayland#145

Open
tranquil-tr0 wants to merge 5 commits intoSathvik-Rao:mainfrom
tranquil-tr0:main
Open

Fix polling/watching clipboard on Linux Wayland#145
tranquil-tr0 wants to merge 5 commits intoSathvik-Rao:mainfrom
tranquil-tr0:main

Conversation

@tranquil-tr0
Copy link

Fix #124 & #135 by implement interaction with ext_data_control_v1 Wayland protocol via pywayland, fixes implementation issues caused by polling (focus stealing, busy wait inefficiency, etc.).

@tranquil-tr0
Copy link
Author

Note that this currently wouldn't work on GNOME/Mutter (and assorted other compositors, though there is implementation across multiple most popular compositors already) (although it would in the future as the protocol is slated to enter stable), but I don't think the previous (polling) implementation would've (worked on mutter) either and the polling with wl-clipboard is still kept as a fallback.

@tranquil-tr0
Copy link
Author

@Stormax181iq
Copy link

This does not fallback correctly. The app will still exit with a ModuleNotFoundError or ImportError if the dependency isn't found because it tries to import in clipboard_monitor_linux.py
I think it might need a try-catch block setting ExtDataControlManagerV1 = None and logging the issue. I can add that it doesn't seem complicated

@Stormax181iq
Copy link

I'm trying it, but can't seem to make it work on my machine using Fedora KDE with KWin updated to 6.6. I'll do troubleshooting on my own.
So what do we do about the polling issue ? Do we keep a system that is visibly not working ? Shouldn't we suspend polling when a contextual menu is opened to avoid the issue ? Isn't there a wayland option to detect if a contextual menu is opened ? And if not, what about the current fallback implementation that is basically not working as intended ?

@Stormax181iq
Copy link

Stormax181iq commented Feb 23, 2026

I have done some research. It appears that tkinter provides a Tk().clipboard_get() function that allows accessing the clipboard contents in a non-destructive way. It might be good for the polling fallback instead of getting wl-paste into a variable. I think that Gtk/Gdk also provides Clipboard access if preferred. I could look into that later in the week if nobody does it in the meantime.

@tranquil-tr0
Copy link
Author

I'm trying it, but can't seem to make it work on my machine using Fedora KDE with KWin updated to 6.6. I'll do troubleshooting on my own.

Are you using the system package (python-pywayland)? In my testing when getting the dependency from uv pip, the required function simply did not exist, the system package had more usable modules.
I used Arch, but I read the Fedora python-pywayland package structure during dev.

@tranquil-tr0
Copy link
Author

I have done some research. It appears that tkinter provides a Tk().clipboard_get() function that allows accessing the clipboard contents in a non-destructive way. It might be good for the polling fallback instead of getting wl-paste into a variable. I think that Gtk/Gdk also provides Clipboard access if preferred. I could look into that later in the week if nobody does it in the meantime.

Another option is to use wl-paste --watch, but this doesn't work unless you force the user to build wl-clipboard, since they've merged the change but their last release was in 2023. The issue with wl-paste --watch can be seen mentioned in the new release issue in wl-clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display server issues detection issues on KDE Neon running wayland

2 participants