osc: make title configurable and use property expansion on it

This commit is contained in:
Ricardo Constantino 2017-03-27 17:44:24 +01:00
parent ebf61267f4
commit dc00ad537f
No known key found for this signature in database
GPG Key ID: EFD16019AE4FF531
2 changed files with 11 additions and 7 deletions

View File

@ -43,7 +43,7 @@ pl next
============= ================================================
title
| Displays current media-title or filename
| Displays current media-title, filename, or custom title
============= ================================================
left-click show playlist position and length and full title
@ -239,6 +239,12 @@ Configurable Options
Duration of fade out in ms, 0 = no fade
``title``
Default: ${media-title}
String that supports property expansion that will be displayed as
OSC title.
``tooltipborder``
Default: 1

View File

@ -34,6 +34,8 @@ local user_opts = {
layout = "bottombar",
seekbarstyle = "bar", -- slider (diamond marker), knob (circle
-- marker with guide), or bar (fill)
title = "${media-title}", -- string compatible with property-expansion
-- to be shown as OSC title
tooltipborder = 1, -- border of tooltip in bottom/topbar
timetotal = false, -- display total time instead of remaining time?
timems = false, -- display timecodes with milliseconds?
@ -1511,12 +1513,8 @@ function osc_init()
ne = new_element("title", "button")
ne.content = function ()
local title = mp.get_property_osd("media-title")
if not (title == nil) then
return (title)
else
return ("mpv")
end
local title = mp.command_native({"expand-text", user_opts.title})
return not (title == "") and title or "mpv"
end
ne.eventresponder["mouse_btn0_up"] = function ()