Skip to content

Instantly share code, notes, and snippets.

@joernassimian
Forked from ekisu/vo_battery.lua
Created December 5, 2019 23:07
Show Gist options
  • Save joernassimian/0e1a388a8a2072fdba63342a3c975e51 to your computer and use it in GitHub Desktop.
Save joernassimian/0e1a388a8a2072fdba63342a3c975e51 to your computer and use it in GitHub Desktop.
vo_battery.lua implementation for Linux
-- If the laptop is on battery, the VO set in the config will be choosen,
-- else the one defined with „hqvo“ is used.
local hqvo = "opengl-hq:interpolation"
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 AC, setting high-quality options.")
mp.set_property("options/vo", hqvo)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment