Skip to content

Commit b461b50

Browse files
refactor(clipshot): use mp.command_native_async
1 parent 9426c55 commit b461b50

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

clipshot.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
utils = require 'mp.utils'
2-
31
NAME = 'mpv-screenshot.png'
42

53
if package.config:sub(1, 1) ~= '/' then -- Windows
64
SHOT = os.getenv('TEMP')..'\\'..NAME
75
CMD = {
8-
'powershell', '-NoProfile', '-Command', string.format([[& {
6+
'powershell', '-NoProfile', '-Command',
7+
string.format([[& {
98
Add-Type -Assembly System.Windows.Forms;
109
Add-Type -Assembly System.Drawing;
1110
$shot = [Drawing.Image]::FromFile(%q);
@@ -32,12 +31,9 @@ end
3231
function clipshot(arg)
3332
return function()
3433
mp.commandv('screenshot-to-file', SHOT, arg)
35-
utils.subprocess_detached({args = CMD})
36-
mp.osd_message('Copied screenshot to clipboard')
37-
-- TODO: switch to new API when it's in stable
38-
-- mp.command_native_async({'run', unpack(CMD)}, function(suc, res, err)
39-
-- mp.osd_message(suc and 'Copied screenshot to clipboard' or err)
40-
-- end)
34+
mp.command_native_async({'run', unpack(CMD)}, function(suc, _, err)
35+
mp.osd_message(suc and 'Copied screenshot to clipboard' or err)
36+
end)
4137
end
4238
end
4339

0 commit comments

Comments
 (0)