aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/coc/extensions/package.json3
-rw-r--r--.config/mpv/input.conf1
-rw-r--r--.config/mpv/scripts/copy-subs.lua23
3 files changed, 22 insertions, 5 deletions
diff --git a/.config/coc/extensions/package.json b/.config/coc/extensions/package.json
index aed1c07..5af9859 100644
--- a/.config/coc/extensions/package.json
+++ b/.config/coc/extensions/package.json
@@ -10,7 +10,8 @@
"coc-python": ">=1.2.12",
"coc-rust-analyzer": ">=0.68.2",
"coc-tsserver": ">=1.5.8",
- "coc-vimtex": ">=1.1.5"
+ "coc-vimtex": ">=1.1.5",
+ "coc-lua": ">=2.0.5"
},
"disabled": [],
"locked": [],
diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf
index 825bfd5..f275370 100644
--- a/.config/mpv/input.conf
+++ b/.config/mpv/input.conf
@@ -1,4 +1,5 @@
ALT+j add sub-scale +0.1
ALT+k add sub-scale -0.1
ALT+c script-message-to copy_subs copy
+ALT+SHIFT+c script-message-to copy_subs auto
diff --git a/.config/mpv/scripts/copy-subs.lua b/.config/mpv/scripts/copy-subs.lua
index ae0aded..32ae7ef 100644
--- a/.config/mpv/scripts/copy-subs.lua
+++ b/.config/mpv/scripts/copy-subs.lua
@@ -1,9 +1,24 @@
-function copy_sub()
- sub = mp.get_property("sub-text", "string")
- if sub and sub ~= '' then
+_G.auto = false
+
+function copy()
+ local sub = mp.get_property("sub-text")
+ if sub then
os.execute("echo '" .. sub:gsub('\'', '\'\\\'\'') .. "' | xclip -selection clipboard -i")
end
end
-mp.add_key_binding(nil, "copy", copy_sub)
+function autocopy()
+ if _G.auto == false then return end
+ copy()
+end
+
+function toggle_autocopy()
+ _G.auto = not _G.auto
+ mp.osd_message("autocopy " .. (_G.auto and "on" or "off"))
+end
+
+mp.add_key_binding(nil, "copy", copy)
+
+mp.observe_property("sub-text", "string", autocopy)
+mp.add_key_binding(nil, "auto", toggle_autocopy)