From cc942a55a19b037a6b52616415a206be86f70709 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 13 May 2020 16:52:06 +0200 Subject: [PATCH] [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. --- mpv/.config/mpv/scripts/battery.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 mpv/.config/mpv/scripts/battery.lua 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