2020-05-13 14:52:06 +00:00
|
|
|
-- If the laptop is on battery, the profile 'lq' will be loaded; otherwise 'hq' is used
|
2020-05-13 15:41:14 +00:00
|
|
|
--
|
|
|
|
local lqprofile = "lowquality"
|
|
|
|
local hqprofile = "highquality"
|
|
|
|
|
|
|
|
local function powerstate()
|
2020-11-06 14:03:33 +00:00
|
|
|
local f = io.open("/sys/class/power_supply/AC/online")
|
|
|
|
if f == nil then return end
|
|
|
|
local t = f:read("*n")
|
|
|
|
f:close()
|
|
|
|
return t
|
2020-05-13 14:52:06 +00:00
|
|
|
end
|
2020-05-13 15:41:14 +00:00
|
|
|
|
|
|
|
local function adjust()
|
2020-11-06 14:03:33 +00:00
|
|
|
local state = powerstate()
|
|
|
|
-- this actually overrides automatically applied profiles
|
|
|
|
-- like 'protocol.http'
|
|
|
|
if state == 0 then
|
|
|
|
mp.msg.info("Running on battery, setting low-quality options.")
|
|
|
|
mp.set_property("profile", lqprofile)
|
|
|
|
else
|
|
|
|
mp.msg.info("Not running on battery, setting high-quality options.")
|
|
|
|
end
|
2020-05-13 14:52:06 +00:00
|
|
|
end
|
2020-05-13 15:41:14 +00:00
|
|
|
mp.add_hook("on_load", 1, adjust)
|