diff options
| author | Robert Günzler <r@gnzler.io> | 2023-09-29 07:09:17 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2023-09-29 07:09:17 +0200 |
| commit | 237a091e44908615df0955243412d50cf49ecf2e (patch) | |
| tree | bf8325a7fd09ebef96450fdb43bf1d4910bf5869 /.config/mpv/scripts/yanky.lua | |
| parent | f5c219983c0f60a07f1bd52b6f6071e86f35455e (diff) | |
update mpv config
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.config/mpv/scripts/yanky.lua')
| -rw-r--r-- | .config/mpv/scripts/yanky.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/.config/mpv/scripts/yanky.lua b/.config/mpv/scripts/yanky.lua new file mode 100644 index 0000000..ded6ba0 --- /dev/null +++ b/.config/mpv/scripts/yanky.lua @@ -0,0 +1,33 @@ +local mp = require("mp") + +function yank(payload) + mp.commandv("run", "wl-copy", payload) + mp.msg.info("yanked: " .. payload) + mp.osd_message("yanked: " .. payload) +end + +function yankproperty(prop) + yank(mp.get_property_native(prop)) +end + +function yankpath() + local path = mp.get_property_native("path") + local cwd = mp.get_property_native("working-directory") + yank(require("mp.utils").join_path(cwd, path)) +end + +function yanktime() + local s = mp.get_property_native("playback-time") + local ts = string.format("%.2d:%.2d:%.2d.%.3d", s / (60 * 60), s / 60 % 60, s % 60, (s % 1) * 1000) + yank(ts) +end + +function yanksubs() + local subText = mp.get_property("sub-text") + -- local secondarySubText = mp.get_property("secondary-sub-text") + yank(subText) +end + +mp.add_key_binding("y-t", "yanktime", yanktime) +mp.add_key_binding("y-p", "yankpath", yankpath) +mp.add_key_binding("y-s", "yanksubs", yanksubs) |