summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-28 22:44:45 +0100
committerwm4 <wm4@nowhere>2014-11-29 00:03:46 +0100
commit9666d48aa332a034d7df72aee320385fb549464d (patch)
tree8afb078dc4cea2ab361912f0fc6b3ded313ed7a8 /TOOLS
parenta72a4b28a07e32ce4fd03aba011f061a05261e1d (diff)
downloadmpv-9666d48aa332a034d7df72aee320385fb549464d.tar.bz2
mpv-9666d48aa332a034d7df72aee320385fb549464d.tar.xz
TOOLS/lua: add script that pauses playback when minimizing the window
Uses functionality that was added a month ago for exactly this purpose. Fixes #1237.
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/pause-when-minimize.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/TOOLS/lua/pause-when-minimize.lua b/TOOLS/lua/pause-when-minimize.lua
new file mode 100644
index 0000000000..62e3ff5d27
--- /dev/null
+++ b/TOOLS/lua/pause-when-minimize.lua
@@ -0,0 +1,22 @@
+-- This script pauses playback when minimizing the window, and resumes playback
+-- if it's brought back again. If the player was already paused when minimizing,
+-- then try not to mess with the pause state.
+
+-- Note: currently works with X11 only.
+
+local did_minimize = false
+
+mp.observe_property("window-minimized", "bool", function(name, value)
+ local pause = mp.get_property_native("pause")
+ if value == true then
+ if pause == false then
+ mp.set_property_native("pause", true)
+ did_minimize = true
+ end
+ elseif value == false then
+ if did_minimize and (pause == true) then
+ mp.set_property_native("pause", false)
+ end
+ did_minimize = false
+ end
+end)