From 76e72f4d464088c72d74f192e0677268f4f79ec7 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 20 Sep 2024 10:31:32 +0200 Subject: [PATCH] mpv: printout marked files using the "M" key similar to sxiv --- .config/mpv/scripts/mark.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .config/mpv/scripts/mark.lua diff --git a/.config/mpv/scripts/mark.lua b/.config/mpv/scripts/mark.lua new file mode 100644 index 0000000..8d6da91 --- /dev/null +++ b/.config/mpv/scripts/mark.lua @@ -0,0 +1,30 @@ +-- mpv script to mark videos +local utils = require 'mp.utils' +local marked_videos = {} +local marked_file = "marked" + +function toggle_mark() + local path = mp.get_property("path") + if marked_videos[path] then + marked_videos[path] = nil + mp.osd_message("Unmarked: " .. path) + else + marked_videos[path] = true + mp.osd_message("Marked: " .. path) + end +end + +function save_marks() + -- Do not write anything if "marked_videos" is empty + if next(marked_videos) == nil then + return + end + local file = io.open(marked_file, "a") + for path, _ in pairs(marked_videos) do + file:write(path .. "\n") + end + file:close() +end + +mp.add_key_binding("M", "toggle_mark", toggle_mark) +mp.register_event("shutdown", save_marks)