mpv: add full path to options

This commit is contained in:
Alexander Bocken 2024-06-04 21:11:12 +02:00
parent e104755b24
commit a2eaec5dba
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -23,9 +23,9 @@ local function handle_y()
end end
-- Function to handle 'n' keypress -- Function to handle 'n' keypress
-- Copy the filename to clipboard
local function handle_n() local function handle_n()
if y_pressed then if y_pressed then
-- Copy the filename to clipboard
local filename = mp.get_property("filename") local filename = mp.get_property("filename")
-- Use a method to copy 'filename' to clipboard (platform-specific) -- Use a method to copy 'filename' to clipboard (platform-specific)
-- For example, on Unix-like systems, you might use 'xclip' -- For example, on Unix-like systems, you might use 'xclip'
@ -36,22 +36,30 @@ local function handle_n()
end end
-- Bind the keys to their respective functions -- Bind the keys to their respective functions
mp.add_key_binding("y", "check_y", handle_y)
mp.add_key_binding("n", "check_n", handle_n)
-- Function to handle 'd' keypress -- Function to handle 'd' keypress
-- Copy the directory to clipboard
local function handle_d() local function handle_d()
if y_pressed then if y_pressed then
-- Copy the directory to clipboard
local filepath = mp.get_property("path") local filepath = mp.get_property("path")
local directory = string.match(filepath, "(.*/)") local directory = string.match(filepath, "(.*/)")
-- Use a method to copy 'directory' to clipboard (platform-specific)
-- For example, on Unix-like systems, you might use 'xclip'
os.execute("echo " .. directory .. " | xclip -selection clipboard") os.execute("echo " .. directory .. " | xclip -selection clipboard")
mp.osd_message("Copied directory " .. directory .. " to clipboard", 3) mp.osd_message("Copied directory " .. directory .. " to clipboard", 3)
reset_y() -- Reset the 'y' keypress state reset_y()
end end
end end
-- Bind the 'd' key to its respective function -- Function to handle 'p' keypress
local function handle_p()
if y_pressed then
local full_path = mp.get_property("path")
os.execute("echo " .. full_path .. " | xclip -selection clipboard")
mp.osd_message("Copied full path " .. full_path .. " to clipboard", 3)
reset_y()
end
end
mp.add_key_binding("y", "check_y", handle_y)
mp.add_key_binding("n", "check_n", handle_n)
mp.add_key_binding("p", "check_p", handle_p)
mp.add_key_binding("d", "check_d", handle_d) mp.add_key_binding("d", "check_d", handle_d)