[mpv] Add auto configuration low power mode

Add low power profile auto-setting if, on opening mpv, the battery mode
is detected. This will not automatically change when laptop is beginning
to charge/discharge *during* mpv being open.
This commit is contained in:
Marty Oehme 2020-05-13 16:52:06 +02:00
parent f5505cbac1
commit cc942a55a1
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A

View file

@ -0,0 +1,17 @@
-- If the laptop is on battery, the profile 'lq' will be loaded; otherwise 'hq' is used
local lqprofile = "lq"
local hqprofile = "hq"
local utils = require 'mp.utils'
if mp.get_property_bool("option-info/vo/set-from-commandline") == true then
return
end
t = {}
t.args = {"/bin/cat", "/sys/class/power_supply/AC/online"}
res = utils.subprocess(t)
if res.stdout == "0\n" then
mp.msg.info("On Battery, setting low-quality options.")
mp.set_property("profile", lqprofile)
mp.set_property("speed", 2)
else
mp.msg.info("On AC, setting high-quality options.")
end