Skip to content

Pure-Python Wayland clipboard backend (ctypes) #6

@djdarcy

Description

@djdarcy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature requestphase 3Phase 3: Rich Content & Native Clipboard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions