Module: Clipboard::LinuxWayland
- Extended by:
- LinuxWayland
- Includes:
- Implementation
- Included in:
- LinuxWayland
- Defined in:
- lib/clipboard/linux_wayland.rb
Constant Summary collapse
- CLIPBOARDS =
%w[clipboard primary].freeze
- TEST_COMMAND =
"wl-copy"
- WRITE_COMMAND =
"wl-copy --type text/plain"
- READ_COMMAND =
"wl-paste --type text/plain --no-newline"
Instance Method Summary collapse
- #clear(clipboard: "all") ⇒ Object
- #copy(data, clipboard: "all") ⇒ Object
- #paste(which = nil, clipboard: "clipboard") ⇒ Object
Instance Method Details
#clear(clipboard: "all") ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/clipboard/linux_wayland.rb', line 43 def clear(clipboard: "all") selections = clipboard.to_s == "all" ? CLIPBOARDS : [clipboard] selections.each{ |selection| raise ArgumentError, "unknown clipboard selection" unless CLIPBOARDS.include?(selection) primary_flag = selection.to_s == "primary" ? " --primary" : "" `#{WRITE_COMMAND}#{primary_flag} --clear` } true end |
#copy(data, clipboard: "all") ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/clipboard/linux_wayland.rb', line 31 def copy(data, clipboard: "all") selections = clipboard.to_s == "all" ? CLIPBOARDS : [clipboard] selections.each{ |selection| raise ArgumentError, "unknown clipboard selection" unless CLIPBOARDS.include?(selection) primary_flag = selection == "primary" ? " --primary" : "" Utils.popen("#{WRITE_COMMAND}#{primary_flag}", data) } true end |
#paste(which = nil, clipboard: "clipboard") ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/clipboard/linux_wayland.rb', line 22 def paste(which = nil, clipboard: "clipboard") selection = which || clipboard raise ArgumentError, "unknown clipboard selection" unless CLIPBOARDS.include?(selection) primary_flag = selection == "primary" ? " --primary" : "" `#{READ_COMMAND}#{primary_flag}` end |