Skip to content

Commit ec236f7

Browse files
committed
osc.lua: add idlescreen and osc-idlescreen
This is mainly for other user scripts that may conflict with the osc logo in some way. Although it is possible to listen for shared-script-properties, this has many edge cases that could easily pop up. A user could want other OSC things to happen at the same time (say osc-message). They just don't want the logo. The idlescreen option disables all idlescreen related things (including the santa hat) if it is set to "no". A new script message (osc-idlescreen) is also added so users can easily toggle the value (passing "cycle" or just explictly setting "yes" or "no"). Some more discussion on this is found in the below github issues. #10201 CogentRedTester/mpv-file-browser#55
1 parent 5c4b0c2 commit ec236f7

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed

DOCS/man/osc.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ Configurable Options
236236

237237
Enable the OSC when fullscreen
238238

239+
``showidlescreen``
240+
Default: yes
241+
242+
Show the mpv logo and message when idle
243+
239244
``scalewindowed``
240245
Default: 1.0
241246

@@ -418,6 +423,10 @@ to set auto mode (the default) with ``b``::
418423
a script-message osc-visibility never
419424
b script-message osc-visibility auto
420425

426+
``osc-idlescreen``
427+
Controls the visibility of the mpv logo on idle. Valid arguments are ``yes``,
428+
``no``, and ``cycle`` to toggle between yes and no.
429+
421430
``osc-playlist``, ``osc-chapterlist``, ``osc-tracklist``
422431
Shows a limited view of the respective type of list using the OSC. First
423432
argument is duration in seconds.

player/lua/osc.lua

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local utils = require 'mp.utils'
1111
local user_opts = {
1212
showwindowed = true, -- show OSC when windowed?
1313
showfullscreen = true, -- show OSC when fullscreen?
14+
idlescreen = true, -- show mpv logo on idle
1415
scalewindowed = 1, -- scaling of the controller when windowed
1516
scalefullscreen = 1, -- scaling of the controller when fullscreen
1617
scaleforcedwindow = 2, -- scaling when rendered on a forced window
@@ -2579,23 +2580,27 @@ function tick()
25792580

25802581
local ass = assdraw.ass_new()
25812582
-- mpv logo
2582-
for i, line in ipairs(logo_lines) do
2583-
ass:new_event()
2584-
ass:append(line_prefix .. line)
2583+
if user_opts.idlescreen then
2584+
for i, line in ipairs(logo_lines) do
2585+
ass:new_event()
2586+
ass:append(line_prefix .. line)
2587+
end
25852588
end
25862589

25872590
-- Santa hat
2588-
if is_december and not user_opts.greenandgrumpy then
2591+
if is_december and user_opts.idlescreen and not user_opts.greenandgrumpy then
25892592
for i, line in ipairs(santa_hat_lines) do
25902593
ass:new_event()
25912594
ass:append(line_prefix .. line)
25922595
end
25932596
end
25942597

2595-
ass:new_event()
2596-
ass:pos(320, icon_y+65)
2597-
ass:an(8)
2598-
ass:append("Drop files or URLs to play here.")
2598+
if user_opts.idlescreen then
2599+
ass:new_event()
2600+
ass:pos(320, icon_y+65)
2601+
ass:an(8)
2602+
ass:append("Drop files or URLs to play here.")
2603+
end
25992604
set_osd(640, 360, ass.text)
26002605

26012606
if state.showhide_enabled then
@@ -2844,9 +2849,35 @@ function visibility_mode(mode, no_osd)
28442849
request_tick()
28452850
end
28462851

2852+
function idlescreen_visibility(mode, no_osd)
2853+
if mode == "cycle" then
2854+
if user_opts.idlescreen then
2855+
mode = "no"
2856+
else
2857+
mode = "yes"
2858+
end
2859+
end
2860+
2861+
if mode == "yes" then
2862+
user_opts.idlescreen = true
2863+
else
2864+
user_opts.idlescreen = false
2865+
end
2866+
2867+
utils.shared_script_property_set("osc-idlescreen", mode)
2868+
2869+
if not no_osd and tonumber(mp.get_property("osd-level")) >= 1 then
2870+
mp.osd_message("OSC logo visibility: " .. tostring(mode))
2871+
end
2872+
2873+
request_tick()
2874+
end
2875+
28472876
visibility_mode(user_opts.visibility, true)
28482877
mp.register_script_message("osc-visibility", visibility_mode)
28492878
mp.add_key_binding(nil, "visibility", function() visibility_mode("cycle") end)
28502879

2880+
mp.register_script_message("osc-idlescreen", idlescreen_visibility)
2881+
28512882
set_virt_mouse_area(0, 0, 0, 0, "input")
28522883
set_virt_mouse_area(0, 0, 0, 0, "window-controls")

0 commit comments

Comments
 (0)