summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-11 17:08:32 +0200
committerwm4 <wm4@nowhere>2014-08-11 17:08:32 +0200
commitf9d2ad6c17337ab18e662b742bb2ef9041bab96c (patch)
tree732f02d20be04b8bbc78a000e60134c01998b868 /TOOLS
parent0ed48f5ec939c50ebd843a17197a7169db33c25b (diff)
downloadmpv-f9d2ad6c17337ab18e662b742bb2ef9041bab96c.tar.bz2
mpv-f9d2ad6c17337ab18e662b742bb2ef9041bab96c.tar.xz
Move status-line.lua
Looks like TOOLS/lua/ is now established as dumping ground for random Lua scripts, so DOCS/lua_examples/ is not needed anymore.
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/status-line.lua69
1 files changed, 69 insertions, 0 deletions
diff --git a/TOOLS/lua/status-line.lua b/TOOLS/lua/status-line.lua
new file mode 100644
index 0000000000..48597c3370
--- /dev/null
+++ b/TOOLS/lua/status-line.lua
@@ -0,0 +1,69 @@
+-- Rebuild the terminal status line as a lua script
+-- Be aware that this will require more cpu power!
+
+-- Add a string to the status line
+function atsl(s)
+ newStatus = newStatus .. s
+end
+
+function update_status_line()
+ -- Reset the status line
+ newStatus = ""
+
+ if mp.get_property_bool("pause") then
+ atsl("(Paused) ")
+ elseif mp.get_property_bool("paused-for-cache") then
+ atsl("(Buffering) ")
+ end
+
+ if mp.get_property("vid") ~= "no" then
+ atsl("A")
+ end
+ if mp.get_property("aid") ~= "no" then
+ atsl("V")
+ end
+
+ atsl(": ")
+
+ atsl(mp.get_property_osd("time-pos"))
+
+ atsl(" / ");
+ atsl(mp.get_property_osd("length"));
+
+ atsl(" (")
+ atsl(mp.get_property_osd("percent-pos", -1))
+ atsl("%)")
+
+ local r = mp.get_property_number("speed", -1)
+ if r ~= 1 then
+ atsl(string.format(" x%4.2f", r))
+ end
+
+ r = mp.get_property_number("avsync", nil)
+ if r ~= nil then
+ atsl(string.format(" A-V: %7.3f", r))
+ end
+
+ r = mp.get_property("total-avsync-change", 0)
+ if math.abs(r) > 0.05 then
+ atsl(string.format(" ct:%7.3f", r))
+ end
+
+ r = mp.get_property_number("drop-frame-count", -1)
+ if r > 0 then
+ atsl(" Late: ")
+ atsl(r)
+ end
+
+ r = mp.get_property_number("cache", 0)
+ if r > 0 then
+ atsl(string.format(" Cache: %d%% ", r))
+ end
+
+ -- Set the new status line
+ mp.set_property("options/term-status-msg", newStatus)
+end
+
+-- Register the event
+mp.register_event("tick", update_status_line)
+