diff --git a/mpv/.config/mpv/scripts/battery.lua b/mpv/.config/mpv/scripts/battery.lua new file mode 100644 index 0000000..a38381e --- /dev/null +++ b/mpv/.config/mpv/scripts/battery.lua @@ -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