This Rust-based program provides seamless synchronization of clipboard contents between X11 and Wayland environments. It supports both Clipboard and Primary selection types, enabling real-time, bidirectional clipboard sharing.
- ✅ Bidirectional Sync: Synchronizes clipboard data between X11 and Wayland
- ✅ Real-time Monitoring: Automatically detects clipboard changes
- ✅ Dual Selection Support: Handles both Clipboard and Primary selections
- ✅ Content Deduplication: Prevents redundant synchronization of identical content
- ✅ UTF-8 Compatible: Full support for multi-byte characters including Chinese
- Rust 1.70 or higher
- Development libraries for X11 and Wayland
xcliputility (for testing purposes)
cargo build --releasecargo run-
Start the program:
cargo run
-
In another terminal, test clipboard operations:
# Test Clipboard selection echo "Test content $(date)" | xclip -selection clipboard # Test Primary selection echo "Primary selection content $(date)" | xclip -selection primary
-
Observe the program output for synchronization logs.
- Creates a hidden window to receive clipboard events
- Periodically checks clipboard ownership changes
- Requests new clipboard content upon change detection and sends it to Wayland
- Uses the
zwlr_data_control_v1protocol to monitor clipboard changes - Reads clipboard content on change and sends it to X11
- Supports setting clipboard content
- Caches content to avoid duplicate synchronization
- Detects clipboard clearing events
- Processes asynchronously to avoid UI blocking
The program outputs detailed logs configurable via environment variables:
# Debug mode (default)
RUST_LOG=debug cargo run
# Info level only
RUST_LOG=info cargo run
# Disable logs except errors
RUST_LOG=error cargo run- Build Failures: Ensure all required development libraries are installed
- Permission Denied: Verify access rights to X11 and Wayland servers
- Sync Failures: Check logs for error messages
- Use
RUST_LOG=debugfor verbose logging - Confirm X11 and Wayland are running properly
- Test clipboard manually with
xclipandwl-paste
x11rb: X11 bindingswayland-client: Wayland client librarywayland-protocols: Wayland protocol definitionstokio: Asynchronous runtimetracing: Logging framework
- X11 Clipboard and Primary selections
- Wayland
zwlr_data_control_v1protocol - UTF-8 text format
This project is licensed under the MIT License.
Contributions are welcome! Please open issues or submit pull requests.