Skip to content

Commit

Permalink
Improve wl-clipboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed Apr 4, 2024
1 parent c39dd6b commit 32c43b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 6 additions & 5 deletions lib/clipboard/linux_wayland.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +29,7 @@ def copy(data)
end

def clear
`#{WRITE_COMMAND} -c`
`#{WRITE_COMMAND} --clear`
end
end
end

0 comments on commit 32c43b5

Please sign in to comment.