From 32c43b5bce7bb4eab3c318421524723504088d0c Mon Sep 17 00:00:00 2001 From: Jan Lelis Date: Thu, 4 Apr 2024 18:16:52 +0200 Subject: [PATCH] Improve wl-clipboard support --- CHANGELOG.md | 4 ++++ lib/clipboard/linux_wayland.rb | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bfa121..507f66d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 1.4.1 (unreleased) +* Always use plaintext mimetype for wl-clipboard +* Do not include newline when pasting from wl-clipboard + ## 1.4.0 * Add Wayland support via `wl-copy`, patch by @cramt * Only silence clipboard warnings when $VERBOSE is nil diff --git a/lib/clipboard/linux_wayland.rb b/lib/clipboard/linux_wayland.rb index 3c7390f..b2f5378 100644 --- a/lib/clipboard/linux_wayland.rb +++ b/lib/clipboard/linux_wayland.rb @@ -6,17 +6,18 @@ module Clipboard module LinuxWayland extend self - WRITE_COMMAND = "wl-copy" - READ_COMMAND = "wl-paste" + TEST_COMMAND = "wl-copy" + WRITE_COMMAND = "wl-copy --type text/plain" + READ_COMMAND = "wl-paste --type text/plain --no-newline" - if !Utils.executable_installed?(WRITE_COMMAND) + if !Utils.executable_installed?(TEST_COMMAND) raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program wl-copy\n" \ "Please install it or try a different implementation" end def paste(might_select_primary_clipboard = nil) if might_select_primary_clipboard == "primary" - `#{READ_COMMAND} -p` + `#{READ_COMMAND} --primary` else `#{READ_COMMAND}` end @@ -28,7 +29,7 @@ def copy(data) end def clear - `#{WRITE_COMMAND} -c` + `#{WRITE_COMMAND} --clear` end end end