Sha256: 7b4b6506947d49e44c608db05ef4db1f73d90d04c0dec25615e5b528d3d36aa5
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require_relative "utils" module Clipboard module Linux extend self CLIPBOARDS = %w[clipboard primary secondary].freeze # check which backend to use if Utils.executable_installed?('xclip') WriteCommand = 'xclip' ReadCommand = 'xclip -o' ReadOutputStream = false Selection = proc{ |x| "-selection #{x}" }.freeze elsif Utils.executable_installed?('xsel') WriteCommand = 'xsel -i' ReadCommand = 'xsel -o' ReadOutputStream = true Selection = { 'clipboard' => '-b', 'primary' => '-p', 'secondary' => '-s' }.freeze else raise Clipboard::ClipboardLoadError, "clipboard: Could not find required program xclip or xsel\n" \ "On debian/ubuntu, you can install it with: sudo apt-get install xclip" end def paste(which = nil) if !which || !CLIPBOARDS.include?(which_normalized = which.to_s.downcase) which_normalized = CLIPBOARDS.first end `#{ReadCommand} #{Selection[which_normalized]} 2> /dev/null` end def clear copy '' end def copy(data) CLIPBOARDS.each{ |which| Utils.popen "#{WriteCommand} #{Selection[which]}", data, ReadOutputStream } paste end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clipboard-1.3.0 | lib/clipboard/linux.rb |