mpv: yanking of title possible
This commit is contained in:
parent
5c345b8a8c
commit
69212cf836
@ -15,7 +15,7 @@ local function reset_y()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Function to handle 'y' keypress
|
-- Function to handle 'y' keypress
|
||||||
local function handle_y()
|
local function handle_yanker()
|
||||||
reset_y()
|
reset_y()
|
||||||
y_pressed = true
|
y_pressed = true
|
||||||
-- Start a timer to reset the state after 2 seconds
|
-- Start a timer to reset the state after 2 seconds
|
||||||
@ -24,7 +24,7 @@ end
|
|||||||
|
|
||||||
-- Function to handle 'n' keypress
|
-- Function to handle 'n' keypress
|
||||||
-- Copy the filename to clipboard
|
-- Copy the filename to clipboard
|
||||||
local function handle_n()
|
local function handle_filename()
|
||||||
if y_pressed then
|
if y_pressed then
|
||||||
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)
|
||||||
@ -39,7 +39,7 @@ end
|
|||||||
|
|
||||||
-- Function to handle 'd' keypress
|
-- Function to handle 'd' keypress
|
||||||
-- Copy the directory to clipboard
|
-- Copy the directory to clipboard
|
||||||
local function handle_d()
|
local function handle_dir()
|
||||||
if y_pressed then
|
if y_pressed then
|
||||||
local filepath = mp.get_property("path")
|
local filepath = mp.get_property("path")
|
||||||
local directory = string.match(filepath, "(.*/)")
|
local directory = string.match(filepath, "(.*/)")
|
||||||
@ -50,7 +50,7 @@ local function handle_d()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Function to handle 'p' keypress
|
-- Function to handle 'p' keypress
|
||||||
local function handle_p()
|
local function handle_path()
|
||||||
if y_pressed then
|
if y_pressed then
|
||||||
local full_path = mp.get_property("path")
|
local full_path = mp.get_property("path")
|
||||||
os.execute("printf %s " .. full_path .. " | xclip -selection clipboard")
|
os.execute("printf %s " .. full_path .. " | xclip -selection clipboard")
|
||||||
@ -59,7 +59,22 @@ local function handle_p()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mp.add_key_binding("y", "check_y", handle_y)
|
-- Function to copy the title to clipboard
|
||||||
mp.add_key_binding("n", "check_n", handle_n)
|
local function handle_title()
|
||||||
mp.add_key_binding("p", "check_p", handle_p)
|
if y_pressed then
|
||||||
mp.add_key_binding("d", "check_d", handle_d)
|
local title = mp.get_property("media-title")
|
||||||
|
if title and title ~= mp.get_property("filename") then
|
||||||
|
os.execute("printf %s" .. title .. " | xclip -selection clipboard")
|
||||||
|
mp.osd_message("Copied title " .. title .. " to clipboard", 3)
|
||||||
|
else
|
||||||
|
handle_filename() -- Call the function to copy the filename
|
||||||
|
end
|
||||||
|
reset_y()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mp.add_key_binding("y", "check_y", handle_yanker)
|
||||||
|
mp.add_key_binding("n", "check_n", handle_filename)
|
||||||
|
mp.add_key_binding("p", "check_p", handle_path)
|
||||||
|
mp.add_key_binding("d", "check_d", handle_dir)
|
||||||
|
mp.add_key_binding("t", "check_t", handle_title)
|
||||||
|
Loading…
Reference in New Issue
Block a user