Skip to content

Commit

Permalink
feat: new commands paste, paste-to-open, paste-to-playlist, `co…
Browse files Browse the repository at this point in the history
…py-to-clipboard`

closes #979
  • Loading branch information
tomasklaen committed Sep 4, 2024
1 parent c00fbfa commit 66cf568
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,22 @@ Show current file in your operating systems' file explorer.
Switch audio output device.
#### `paste`, `paste-to-open`, `paste-to-playlist`
Commands to paste path or URL in clipboard to either open immediately, or append to playlist.
`paste` will add to playlist if there's any (`playlist-count > 1`), or open immediately otherwise.
Note: there are alternative ways to open stuff from clipboard without the need to bind these commands:
- When `open-file` menu is open → `ctrl+v` to open path/URL in clipboard.
- When `playlist` menu is open → `ctrl+v` to add path/URL in clipboard to playlist.
- When any track menu (`subtitles`, `audio`, `video`) is open → `ctrl+v` to add path/URL in clipboard as a new track.
#### `copy-to-clipboard`
Copy currently open path or URL to clipboard.
#### `open-config-directory`
Open directory with `mpv.conf` in file explorer.
Expand Down
16 changes: 16 additions & 0 deletions src/uosc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,22 @@ bind_command('audio-device', create_self_updating_menu_opener({
end,
on_activate = function(event) mp.commandv('set', 'audio-device', event.value) end,
}))
bind_command('paste', function()
local has_playlist = mp.get_property_native('playlist-count') > 1
mp.commandv('script-binding', 'uosc/paste-to-' .. (has_playlist and 'playlist' or 'open'))
end)
bind_command('paste-to-open', function()
local payload = get_clipboard()
if payload then mp.commandv('loadfile', payload) end
end)
bind_command('paste-to-playlist', function()
local payload = get_clipboard()
if payload then
mp.commandv('loadfile', payload, 'append')
mp.commandv('show-text', t('Added to playlist') .. ': ' .. payload, 3000)
end
end)
bind_command('copy-to-clipboard', function() set_clipboard(state.path) end)
bind_command('open-config-directory', function()
local config_path = mp.command_native({'expand-path', '~~/mpv.conf'})
local config = serialize_path(normalize_path(config_path))
Expand Down

0 comments on commit 66cf568

Please sign in to comment.