aboutsummaryrefslogtreecommitdiff
path: root/.config/mpv/scripts/copy-subs.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/mpv/scripts/copy-subs.lua')
-rw-r--r--.config/mpv/scripts/copy-subs.lua32
1 files changed, 0 insertions, 32 deletions
diff --git a/.config/mpv/scripts/copy-subs.lua b/.config/mpv/scripts/copy-subs.lua
deleted file mode 100644
index 973e1f2..0000000
--- a/.config/mpv/scripts/copy-subs.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-_G.auto = false
-
-function copy()
- local sub = mp.get_property("sub-text")
- if sub then
- -- remove some specific unicode characters
- sub = sub:gsub('\u{27a1}', '')
- sub = sub:gsub('\u{fffd}', '')
- sub = sub:gsub('\u{3013}', '')
- sub = sub:gsub('\u{2015}', '')
-
- sub = sub:gsub('\n', ' ') -- replace newlines with space
- sub = sub:gsub('\'', '\'\\\'\'') -- escape single quotes
- os.execute("echo '" .. sub .. "' | xclip -selection clipboard -i")
- end
-end
-
-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)
-