Summary
Implement a pure-Python Wayland clipboard backend using ctypes to libwayland-client.so, eliminating the need for wl-clipboard on Wayland-based Linux systems.
Motivation
Modern Linux distributions (Ubuntu 22.04+, Fedora 34+) default to Wayland. Currently teeclip requires wl-clipboard (wl-copy/wl-paste) to be installed.
Approach
Use ctypes to interact with the Wayland compositor's data device protocol:
- Connect to Wayland display via
wl_display_connect
- Get
wl_data_device_manager from registry
- For copy: create
wl_data_source, set mime type, offer data
- For paste: get
wl_data_offer from wl_data_device, receive data
Challenges
- Wayland protocol is more complex than X11 for clipboard operations
- Requires understanding the data device protocol
- May need to handle multiple MIME types
- Less documentation available for ctypes approach compared to X11
Fallback Chain
Auto-detect order (Wayland):
1. wl-copy/wl-paste (subprocess) — if installed
2. Wayland ctypes — pure Python fallback
3. Fall through to X11 backends (XWayland compatibility)
4. Error with install instructions
Related
Summary
Implement a pure-Python Wayland clipboard backend using
ctypestolibwayland-client.so, eliminating the need forwl-clipboardon Wayland-based Linux systems.Motivation
Modern Linux distributions (Ubuntu 22.04+, Fedora 34+) default to Wayland. Currently teeclip requires
wl-clipboard(wl-copy/wl-paste) to be installed.Approach
Use
ctypesto interact with the Wayland compositor's data device protocol:wl_display_connectwl_data_device_managerfrom registrywl_data_source, set mime type, offer datawl_data_offerfromwl_data_device, receive dataChallenges
Fallback Chain
Related