zydezu / ModernX

My fork of modernX (a replacement for MPV that retains the functionality of the default OSC), adding additional features - see builds at: https://github.com/zydezu/mpvconfig
138 stars 5 forks source link

Title color to respect osd-color option #42

Open bt4ibwem8 opened 3 months ago

bt4ibwem8 commented 3 months ago

Would be nice if you remove \\1c&HFFFFFF&\\3c&H0 from the script, so changing osd-color in mpv.conf would affect also the color of the title (not just color of playlist items).

Samillion commented 1 month ago

The osd-color property uses Hex color, I created a PR #53 to allow this, but this should be fairly simple to implement

in user_opts:

    title_color = '#FFFFFF',        -- color of title, in Hex color format
    title_color_mpvconf = false,    -- Use osd-color set in mpv.conf? Default: false

Anywhere before local osc_styles

user_opts.title_color = user_opts.title_color_mpvconf and mp.get_property("osd-color") or user_opts.title_color

and change in local osc_styles:

Title = '{\\blur1\\bord0.5\\1c&H' .. osc_color_convert(user_opts.title_color) .. '&\\3c&H0\\fs'.. user_opts.titlefontsize ..'\\q2\\fn' .. user_opts.font .. '}',

This requires the osc_color_convert() function because osd-color default value is in hex, which is included in the PR:

local function osc_color_convert(color)
    return color:sub(6,7) .. color:sub(4,5) ..  color:sub(2,3)
end

Examples for modernx.conf:

title_color_mpvconf=no
title_color=#be4d25

image

and setting title_color_mpvconf to yes grabs the osd-color value from mpv conf instead of user_opts:

title_color_mpvconf=yes
title_color=#be4d25

image

Samillion commented 1 month ago

A better approach: Since there are many set with \\1c&HFFFFFF&\\3c&H0, to use a global one instead. For example:

in user_opts:

    osd_color_mpv = false,     -- Use osd-color from mpv? Default: false
    osd_color = '#FFFFFF',     -- Custom color for OSD.

Before local osc_styles:

local function osc_color_convert(color)
    return color:sub(6,7) .. color:sub(4,5) ..  color:sub(2,3)
end

Replace all FFFFFF with: (ie: replacement in \\1c&HFFFFFF&\\3c&H0)

' .. osc_color_convert(user_opts.osd_color_mpv and mp.get_property("osd-color") or user_opts.osd_color) .. '

In modernx.conf:

osd_color_mpv=no
osd_color=#be4d25

You can then replace the property based on the user_opts. As in mp.get_property("osd-color"), replace osd-color to match a border value, whatever you want it to grab from mpv that matches the user_opts use.

bt4ibwem8 commented 1 month ago

I see osd-color in the default osc does not affect the title color. But script-opts-append=osc-title_color does. So maybe the best approach would be Modernx script to respect (by default) the value of script-opts-append=osc-title_color in mpv.conf file. So if i want to have the title color in yellow, then all scripts (including Modernx) would take this info directly from mpv.conf