summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-08-07 19:41:44 +0200
committerwm4 <wm4@nowhere>2020-08-07 19:41:56 +0200
commit4c72202eb1d0e772c81e8137e1772aafec486db4 (patch)
tree8eb1810f4b5142d1c33f4086aaa083843f61949e /player
parent1f132c675a18f0b80fc3159a7b13b5b061f2d93c (diff)
downloadmpv-4c72202eb1d0e772c81e8137e1772aafec486db4.tar.bz2
mpv-4c72202eb1d0e772c81e8137e1772aafec486db4.tar.xz
auto_profiles: unapply conditional profiles if declared
Uses the mechanism introduced in the previous commit. The hope was to make auto-profiles easier to use, and to get rid of the need for manually created inverse profiles. Not sure if the end result is useful.
Diffstat (limited to 'player')
-rw-r--r--player/lua/auto_profiles.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/player/lua/auto_profiles.lua b/player/lua/auto_profiles.lua
index 33271ec8c8..6856138d97 100644
--- a/player/lua/auto_profiles.lua
+++ b/player/lua/auto_profiles.lua
@@ -30,9 +30,14 @@ local function evaluate(profile)
.. type(res) .. ".")
res = false
end
- if res ~= profile.status and res == true then
- msg.info("Applying auto profile: " .. profile.name)
- mp.commandv("apply-profile", profile.name)
+ if res ~= profile.status then
+ if res == true then
+ msg.info("Applying auto profile: " .. profile.name)
+ mp.commandv("apply-profile", profile.name)
+ elseif profile.status == true and profile.has_restore_opt then
+ msg.info("Restoring profile: " .. profile.name)
+ mp.commandv("apply-profile", profile.name, "restore")
+ end
end
profile.status = res
profile.dirty = false
@@ -154,6 +159,7 @@ local function load_profiles()
properties = {},
status = nil,
dirty = true, -- need re-evaluate
+ has_restore_opt = v["profile-restore"] ~= "default"
}
profiles[#profiles + 1] = profile
have_dirty_profiles = true
@@ -164,7 +170,7 @@ end
load_profiles()
if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then
- -- make it exist immediately
+ -- make it exit immediately
_G.mp_event_loop = function() end
return
end