-
Notifications
You must be signed in to change notification settings - Fork 6
Improve xclip compatibility for terminal emulators #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…creenshot and clipboard operations
…y in OCR4Linux.sh for X11 for primary pasting (middle click in the mouse)
|
Caution Review failedFailed to post review comments 📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughVersion bump to 1.4.0 with enhanced logging for screenshot and clipboard operations in the main script, extended X11 clipboard handling to support both clipboard and primary selections via a new orchestrator function, and added user-facing status messages throughout the setup flow. Changes
Sequence DiagramsequenceDiagram
participant User
participant Script as OCR4Linux.sh
participant SessionCheck as Session Detector
participant Wayland as Wayland Clipboard<br/>(wl-copy)
participant X11 as X11 Clipboard<br/>(xclip)
participant FileSystem as File System
User->>Script: Trigger OCR operation
Script->>Script: Capture screenshot & run OCR
Script->>Script: Log: "Copying text to clipboard"
Script->>SessionCheck: Determine session type
alt Wayland Session
SessionCheck-->>Script: Wayland detected
Script->>Wayland: wl-copy < text_file
Script->>Script: Log: "Text copied to Wayland clipboard"
else X11 Session
SessionCheck-->>Script: X11 detected
Script->>X11: xclip -selection clipboard
Script->>Script: Log: "Copied to X11 clipboard"
Script->>X11: xclip -selection primary
Script->>Script: Log: "Copied to X11 primary selection"
end
Script->>FileSystem: Remove temporary text file
Script->>Script: Log: "Cleanup complete"
Script-->>User: Operation finished
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves xclip compatibility for terminal emulators on X11 systems by removing the strict MIME type flag and adding support for the Primary selection (middle-click paste) in addition to the Clipboard selection (Ctrl+V paste). The changes also include enhanced logging throughout the script and version updates across all relevant files.
Changes:
- Removed
-t text/plainflag from xclip commands to improve terminal emulator compatibility - Added Primary selection support for X11 clipboard operations (middle-click paste)
- Enhanced logging messages in setup.sh and OCR4Linux.sh for better user feedback
- Updated version from 1.3.0 to 1.4.0 across all three main files
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| OCR4Linux.sh | Core fix: Modified copy_to_x11_clipboard() to remove MIME type flag and add Primary selection support; added logging statements throughout |
| OCR4Linux.py | Version update to 1.4.0 |
| setup.sh | Version update to 1.4.0 and added informative echo statements for better user experience during setup |
| .gitignore | Added entry to ignore VS Code AI rules file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @0xrego this pr closes your issue successfully, I've tried the fix on Plasma (X11) with Kitty terminal and it's working great :) let me know if you need anything else |
Overview
This PR resolves issue #22 by improving xclip compatibility for terminal emulators on X11 systems. The fix addresses the two main clipboard compatibility issues identified in the issue:
-t text/plainflag from xclip commands that was causing compatibility issues with various terminal emulatorsProblem Statement
Previously, OCR4Linux only copied extracted text to the Clipboard selection, which caused pasting to fail in many terminal emulators. Additionally, some terminals were picky about the MIME type targets provided by xclip, specifically the
-t text/plainflag.Solution
Modified the
copy_to_x11_clipboard()function inOCR4Linux.shto:Changes Made
File: OCR4Linux.sh
File: OCR4Linux.py
Testing
The fix ensures that:
Benefits
Related Issue
Closes #22
Version Update