merge macos and gnu clipboard implementations
This commit is contained in:
parent
667b8c432c
commit
5a15827d7a
21
platform.lua
21
platform.lua
|
@ -45,22 +45,19 @@ this.clipboard = (function()
|
||||||
self.copy = function(text)
|
self.copy = function(text)
|
||||||
return h.subprocess({ self.clip_exe, '-command', 'Set-Clipboard -Value ' .. text })
|
return h.subprocess({ self.clip_exe, '-command', 'Set-Clipboard -Value ' .. text })
|
||||||
end
|
end
|
||||||
elseif this.platform == this.Platform.macos then
|
else
|
||||||
|
if this.platform == this.Platform.macos then
|
||||||
self.clip_exe = "pbcopy"
|
self.clip_exe = "pbcopy"
|
||||||
self.copy = function(text)
|
self.clip_cmd = "LANG=en_US.UTF-8 pbcopy"
|
||||||
local handle = io.popen("LANG=en_US.UTF-8 pbcopy", 'w')
|
elseif h.is_wayland() then
|
||||||
if handle then
|
self.clip_exe = "wl-copy"
|
||||||
handle:write(text)
|
self.clip_cmd = "wl-copy"
|
||||||
local suc, exit, code = handle:close()
|
|
||||||
return { status = code }
|
|
||||||
else
|
else
|
||||||
return { status = 1 }
|
self.clip_exe = "xclip"
|
||||||
|
self.clip_cmd = "xclip -i -selection clipboard"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
|
||||||
self.clip_exe = h.is_wayland() and "wl-copy" or "xclip"
|
|
||||||
self.copy = function(text)
|
self.copy = function(text)
|
||||||
local handle = io.popen(h.is_wayland() and "wl-copy" or "xclip -i -selection clipboard", 'w')
|
local handle = io.popen(self.clip_cmd, 'w')
|
||||||
if handle then
|
if handle then
|
||||||
handle:write(text)
|
handle:write(text)
|
||||||
local suc, exit, code = handle:close()
|
local suc, exit, code = handle:close()
|
||||||
|
|
Loading…
Reference in a new issue