From ffb516b57910ddf8a8813991c6ee7f2e5a385fef Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Thu, 28 Sep 2023 13:15:30 +0300 Subject: [PATCH] fix(clipshot): fix platform detection [take 2] --- clipshot.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/clipshot.lua b/clipshot.lua index d65ef89..310c216 100644 --- a/clipshot.lua +++ b/clipshot.lua @@ -9,16 +9,8 @@ require('mp.options').read_options(o, 'clipshot') local file, cmd -local lib = package.cpath:match('%p[\\|/]?%p(%a+)') -if lib == 'so' then -- Linux/BSD - file = '/tmp/'..o.name - if os.getenv('XDG_SESSION_TYPE') == 'wayland' then -- Wayland - cmd = {'sh', '-c', ('wl-copy < %q'):format(file)} - else -- Xorg - local type = o.type ~= '' and o.type or 'image/jpeg' - cmd = {'xclip', '-sel', 'c', '-t', type, '-i', file} - end -elseif lib ~= 'dylib' then -- Windows +local platform = mp.get_property_native('platform') +if platform == 'windows' then file = os.getenv('TEMP')..'\\'..o.name cmd = { 'powershell', '-NoProfile', '-Command', ([[& { @@ -28,7 +20,7 @@ elseif lib ~= 'dylib' then -- Windows [Windows.Forms.Clipboard]::SetImage($shot); }]]):format(file) } -else -- MacOS +elseif platform == 'darwin' then file = os.getenv('TMPDIR')..'/'..o.name -- png: «class PNGf» local type = o.type ~= '' and o.type or 'JPEG picture' @@ -38,6 +30,14 @@ else -- MacOS read (POSIX file %q) as %s) ]]):format(file, type) } +else + file = '/tmp/'..o.name + if os.getenv('XDG_SESSION_TYPE') == 'wayland' then + cmd = {'sh', '-c', ('wl-copy < %q'):format(file)} + else + local type = o.type ~= '' and o.type or 'image/jpeg' + cmd = {'xclip', '-sel', 'c', '-t', type, '-i', file} + end end ---@param arg string