@@ -9,16 +9,8 @@ require('mp.options').read_options(o, 'clipshot')
99
1010local file , cmd
1111
12- local lib = package.cpath :match (' %p[\\ |/]?%p(%a+)' )
13- if lib == ' so' then -- Linux/BSD
14- file = ' /tmp/' .. o .name
15- if os.getenv (' XDG_SESSION_TYPE' ) == ' wayland' then -- Wayland
16- cmd = {' sh' , ' -c' , (' wl-copy < %q' ):format (file )}
17- else -- Xorg
18- local type = o .type ~= ' ' and o .type or ' image/jpeg'
19- cmd = {' xclip' , ' -sel' , ' c' , ' -t' , type , ' -i' , file }
20- end
21- elseif lib ~= ' dylib' then -- Windows
12+ local platform = mp .get_property_native (' platform' )
13+ if platform == ' windows' then
2214 file = os.getenv (' TEMP' ).. ' \\ ' .. o .name
2315 cmd = {
2416 ' powershell' , ' -NoProfile' , ' -Command' , ([[ & {
@@ -28,7 +20,7 @@ elseif lib ~= 'dylib' then -- Windows
2820 [Windows.Forms.Clipboard]::SetImage($shot);
2921 }]] ):format (file )
3022 }
31- else -- MacOS
23+ elseif platform == ' darwin ' then
3224 file = os.getenv (' TMPDIR' ).. ' /' .. o .name
3325 -- png: «class PNGf»
3426 local type = o .type ~= ' ' and o .type or ' JPEG picture'
@@ -38,6 +30,14 @@ else -- MacOS
3830 read (POSIX file %q) as %s)
3931 ]] ):format (file , type )
4032 }
33+ else
34+ file = ' /tmp/' .. o .name
35+ if os.getenv (' XDG_SESSION_TYPE' ) == ' wayland' then
36+ cmd = {' sh' , ' -c' , (' wl-copy < %q' ):format (file )}
37+ else
38+ local type = o .type ~= ' ' and o .type or ' image/jpeg'
39+ cmd = {' xclip' , ' -sel' , ' c' , ' -t' , type , ' -i' , file }
40+ end
4141end
4242
4343--- @param arg string
0 commit comments