[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:
parent
f5505cbac1
commit
cc942a55a1
1 changed files with 17 additions and 0 deletions
17
mpv/.config/mpv/scripts/battery.lua
Normal file
17
mpv/.config/mpv/scripts/battery.lua
Normal 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
|
Loading…
Reference in a new issue