Skip to content

Commit 66cf568

Browse files
committed
feat: new commands paste, paste-to-open, paste-to-playlist, copy-to-clipboard
closes #979
1 parent c00fbfa commit 66cf568

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,22 @@ Show current file in your operating systems' file explorer.
313313
314314
Switch audio output device.
315315
316+
#### `paste`, `paste-to-open`, `paste-to-playlist`
317+
318+
Commands to paste path or URL in clipboard to either open immediately, or append to playlist.
319+
320+
`paste` will add to playlist if there's any (`playlist-count > 1`), or open immediately otherwise.
321+
322+
Note: there are alternative ways to open stuff from clipboard without the need to bind these commands:
323+
324+
- When `open-file` menu is open → `ctrl+v` to open path/URL in clipboard.
325+
- When `playlist` menu is open → `ctrl+v` to add path/URL in clipboard to playlist.
326+
- When any track menu (`subtitles`, `audio`, `video`) is open → `ctrl+v` to add path/URL in clipboard as a new track.
327+
328+
#### `copy-to-clipboard`
329+
330+
Copy currently open path or URL to clipboard.
331+
316332
#### `open-config-directory`
317333
318334
Open directory with `mpv.conf` in file explorer.

src/uosc/main.lua

+16
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,22 @@ bind_command('audio-device', create_self_updating_menu_opener({
10741074
end,
10751075
on_activate = function(event) mp.commandv('set', 'audio-device', event.value) end,
10761076
}))
1077+
bind_command('paste', function()
1078+
local has_playlist = mp.get_property_native('playlist-count') > 1
1079+
mp.commandv('script-binding', 'uosc/paste-to-' .. (has_playlist and 'playlist' or 'open'))
1080+
end)
1081+
bind_command('paste-to-open', function()
1082+
local payload = get_clipboard()
1083+
if payload then mp.commandv('loadfile', payload) end
1084+
end)
1085+
bind_command('paste-to-playlist', function()
1086+
local payload = get_clipboard()
1087+
if payload then
1088+
mp.commandv('loadfile', payload, 'append')
1089+
mp.commandv('show-text', t('Added to playlist') .. ': ' .. payload, 3000)
1090+
end
1091+
end)
1092+
bind_command('copy-to-clipboard', function() set_clipboard(state.path) end)
10771093
bind_command('open-config-directory', function()
10781094
local config_path = mp.command_native({'expand-path', '~~/mpv.conf'})
10791095
local config = serialize_path(normalize_path(config_path))

0 commit comments

Comments
 (0)