Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/CogentRedTester/mpv-clipboard
Provides generic low-level clipboard commands for users and script writers.
https://github.com/CogentRedTester/mpv-clipboard
Last synced: 2 months ago
JSON representation
Provides generic low-level clipboard commands for users and script writers.
- Host: GitHub
- URL: https://github.com/CogentRedTester/mpv-clipboard
- Owner: CogentRedTester
- License: mit
- Created: 2022-11-08T08:54:54.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T08:02:51.000Z (about 2 years ago)
- Last Synced: 2024-11-13T12:41:41.341Z (2 months ago)
- Language: Lua
- Size: 13.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mpv - clipboard - Provides a set of generic commands to interact with the clipboard. Specifically it allows user to copy arbitrary text to the clipboard and provides the ability to paste the contents of the clipboard into other commands. (Other)
README
# mpv-clipboard
Provides generic but powerful low-level clipboard commands for users and script writers.
Requires `powershell` on Windows,`pbcopy`/`pbpaste` on MacOS, `xclip` on X11, and `wl-copy`/`wl-paste` on Wayland.
## Script Messages
### set-clipboard
`script-message set-clipboard `
A script message that can be set in `input.conf` to copy the given text into the clipboard.
Can be combined with [property expansion](https://mpv.io/manual/master/#property-expansion)
to copy any mpv property.For example to copy the path of the current file with Ctrl+c:
`Ctrl+c script-message set-clipboard ${path}`
### get-clipboard
`script-message get-clipboard `
Sends the contents of the clipboard to the given script-message. This can be used by other
scripts to request the contents of the clipboard. The other script should register a script-message
with the same name as the `response-string` to receive the clipboard contents.Additional arguments may be introduced in the future.
### clipboard-command
`script-message clipboard-command ...`
Allows one to use the contents of the clipboard in a command. If the command
or arg strings contain the substring `%clip%` then it will be substituted for the
contents of the clipboard.For example to tell mpv to play the contents of the clipboard:
Ctrl+v script-message clipboard-command loadfile %clip%
The `%` character will act as an escape character;
`%%clip%` will evaluate to `%clip%`. Any `%%` will be substituted for `%`, so you may need
to use additional `%` characters if you actually want multiple in a row.By default these commands behave asynchronously, meaning if you send multiple commands at the same time there
no guarantee that the first will be run before the second:Ctrl+t script-message clipboard-command print-text 1 ; script-message clipboard-command print-text 2
To handle this you can set the first [input command prefix](https://mpv.io/manual/master/#input-command-prefixes)
to `sync`, that will ensure that the commands are run in order. Note that all of the usual
[sync vs async rules](https://mpv.io/manual/master/#synchronous-vs-asynchronous) still apply. This behaviour may be moved to a separate script-message in te future.## Credits
The code to get text from the clipboard comes from mpv's [console.lua](https://github.com/mpv-player/mpv/blob/master/player/lua/console.lua).
The code to set the clipboard text on Unix systems was based on [mpv-copyTime](https://github.com/Arieleg/mpv-copyTime).