Skip to content

Fix: Linux clipboard fallback skips xsel when xclip is not installed#4

Open
TofuGG wants to merge 1 commit into
phlx0:mainfrom
TofuGG:something
Open

Fix: Linux clipboard fallback skips xsel when xclip is not installed#4
TofuGG wants to merge 1 commit into
phlx0:mainfrom
TofuGG:something

Conversation

@TofuGG

@TofuGG TofuGG commented Jun 6, 2026

Copy link
Copy Markdown

What does this PR do?

On Linux, copy_to_clipboard() tried xclip and xsel as fallbacks inside a single shared try/except block. If xclip wasn't installed, the FileNotFoundError it raised escaped the loop and was caught by the outer handler — meaning xsel was never tried. Users with xsel but not xclip (common on Debian/Ubuntu) would silently fail to copy even though a working tool was present.

The fix wraps each command in its own try/except inside the loop, so a missing tool just continues to the next candidate. The macOS and Windows branches are also given their own try/except blocks for the same reason.

Three regression tests are added covering: xsel succeeding when xclip is absent, xclip succeeding when xsel is absent, and False returned cleanly when neither tool is installed.

Related issue

No related issue.

Checklist

  • Tests pass (make test)
  • New behaviour is covered by tests (if applicable)
  • CHANGELOG.md updated under [Unreleased]
## [Unreleased]

### Fixed
- Clipboard fallback on Linux now correctly tries `xsel` when `xclip` is not
  installed. Previously both commands shared a single `try/except`, so a
  `FileNotFoundError` from `xclip` aborted the loop before `xsel` was ever
  attempted.

Refactor clipboard handling for better error management and support for Linux commands.
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.

1 participant