diff --git a/README.md b/README.md index 2574ff9..537535a 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,5 @@ First invoke the script using `alt + u`, input a movie name, or use the one prov As the name suggests this is a small script for deleting files played through mpv. You can mark a file to be deleted and can unmark it if desired. Once quitting mpv, the script starts the deletion process. This is platform-agnostic so should work everywhere. `ctrl + DEL`: mark/unmark file to be deleted +`alt + DEL`: show the list of files marked for deletion +`ctrl + shift + DEL`: clear the list of marks diff --git a/delete_file.lua b/delete_file.lua index ca78398..635b1dc 100644 --- a/delete_file.lua +++ b/delete_file.lua @@ -36,5 +36,37 @@ function delete() end end +function showList() + local delString = "Delete Marks:\n" + for _,v in pairs(del_list) do + local dFile = v:gsub("/","\\") + delString = delString..dFile:match("\\*([^\\]*)$").."; " + end + if delString:find(";") then + mp.osd_message(delString) + return delString + elseif showListTimer then + showListTimer:kill() + end +end +showListTimer = mp.add_periodic_timer(1,showList) +showListTimer:kill() +function list_marks() + if showListTimer:is_enabled() then + showListTimer:kill() + mp.osd_message("",0) + else + local delString = showList() + if delString and delString:find(";") then + showListTimer:resume() + print(delString) + else + showListTimer:kill() + end + end +end + mp.add_key_binding("ctrl+DEL", "delete_file", mark_delete) +mp.add_key_binding("alt+DEL", "list_marks", list_marks) +mp.add_key_binding("ctrl+shift+DEL", "clear_list", function() mp.osd_message("Undelete all"); del_list = {}; end) mp.register_event("shutdown", delete)