Sha256: b3ea438f2a1d76d8e95a174431941e27c1912bdc6e271ceeb4be91c4bd4ecf7d

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

require_relative "utils"

module Clipboard
  module LinuxWayland
    extend self

    TEST_COMMAND  = "wl-copy"
    WRITE_COMMAND = "wl-copy --type text/plain"
    READ_COMMAND  = "wl-paste --type text/plain --no-newline"

    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} --primary`
      else
        `#{READ_COMMAND}`
      end
    end

    def copy(data)
      Utils.popen WRITE_COMMAND, data
      paste
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clipboard-1.4.1 lib/clipboard/linux_wayland.rb