Skip to content

Commit 55f6844

Browse files
committed
Add text/uri-list support for paste_img
1 parent 14e0427 commit 55f6844

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/obsidian/img_paste.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ local function clipboard_is_img()
4040
-- See: [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme)
4141
local this_os = util.get_os()
4242
if this_os == util.OSType.Linux or this_os == util.OSType.FreeBSD then
43-
return vim.tbl_contains(content, "image/png")
43+
if vim.tbl_contains(content, "image/png") then
44+
return true
45+
elseif vim.tbl_contains(content, "text/uri-list") then
46+
local success =
47+
os.execute "wl-paste --type text/uri-list | sed 's|file://||' | head -n1 | tr -d '[:space:]' | xargs -I{} sh -c 'wl-copy < \"$1\"' _ {}"
48+
return success == 0
49+
end
4450
elseif this_os == util.OSType.Darwin then
4551
return string.sub(content[1], 1, 9) == "iVBORw0KG" -- Magic png number in base64
4652
elseif this_os == util.OSType.Windows or this_os == util.OSType.Wsl then

0 commit comments

Comments
 (0)