chore(clipboard): separate logic to save as base64 and files (#329)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-08-28 11:52:12 -04:00
committed by GitHub
parent 2c450b1da3
commit 755c15c0bd
9 changed files with 89 additions and 9 deletions

View File

@@ -37,7 +37,22 @@ M.has_content = function()
return false
end
M.get_content = function()
M.save_content = function(filepath)
local cmd = M.get_clip_cmd()
---@type vim.SystemCompleted
local output
if cmd == "xclip" then
output = Utils.shell_run(('xclip -selection clipboard -o -t image/png > "%s"'):format(filepath))
return output.code == 0
elseif cmd == "wl-paste" then
output = Utils.shell_run(('wl-paste --type image/png > "%s"'):format(filepath))
return output.code == 0
end
return false
end
M.get_base64_content = function()
local cmd = M.get_clip_cmd()
---@type vim.SystemCompleted
local output