From 61e5074af37849a983a3eb31ed2479c6c600e979 Mon Sep 17 00:00:00 2001 From: Nulo Date: Tue, 5 Apr 2022 14:12:34 -0300 Subject: [PATCH] mpv --- .config/mpv/mpv.conf | 5 +++++ .config/mpv/scripts/playlist.lua | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 .config/mpv/mpv.conf create mode 100644 .config/mpv/scripts/playlist.lua diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf new file mode 100644 index 0000000..43cc79c --- /dev/null +++ b/.config/mpv/mpv.conf @@ -0,0 +1,5 @@ +sub-font=Inter +sub-blur=10 +slang=eng,spa +save-position-on-quit=yes +hwdec=vaapi diff --git a/.config/mpv/scripts/playlist.lua b/.config/mpv/scripts/playlist.lua new file mode 100644 index 0000000..c965427 --- /dev/null +++ b/.config/mpv/scripts/playlist.lua @@ -0,0 +1,34 @@ +mp.add_key_binding("y", "fzf", function () + local pl = mp.get_property_native("playlist") + if not pl then return end + + local input_path = os.tmpname() + local input_file = io.open(input_path, "w") + for i, v in pairs(pl) do + local desc = v.filename + if v.title then desc = v.title end + input_file:write(i-1 .. ": " .. desc .. "\n") + end + input_file:close() + + local output_path = os.tmpname() + os.execute("footclient bash -i -c 'cat "..input_path.." | fzf --no-sort > "..output_path.."'") + + local output_file = io.open(output_path, "r") + local line = output_file:read("*l") + output_file:close() + os.remove(output_path) + + if line then + local index = string.match(line, "%d+") + mp.commandv("playlist-play-index", index) + end + + os.remove(input_path) +end) + +mp.observe_property("media-title", "native", function (name, value) + if value then + print("Playing: " .. value) + end +end)