lua: Format with stylua

This commit is contained in:
Marty Oehme 2023-06-15 10:12:30 +02:00
parent e434c191c9
commit 5f93ecba7c
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
33 changed files with 4062 additions and 3413 deletions

View file

@ -1,5 +1,5 @@
-- If the laptop is on battery, the profile 'lq' will be loaded; otherwise 'hq' is used
local mp = require 'mp'
local mp = require("mp")
local SHOULD_ADJUST = false
@ -7,27 +7,31 @@ local lqprofile = "lowquality"
local hqprofile = "highquality"
local function powerstate()
local f = io.open("/sys/class/power_supply/AC/online")
if f == nil then return end
local t = f:read("*n")
f:close()
return t
local f = io.open("/sys/class/power_supply/AC/online")
if f == nil then
return
end
local t = f:read("*n")
f:close()
return t
end
local function adjust()
if not SHOULD_ADJUST then return end
if not SHOULD_ADJUST then
return
end
local state = powerstate()
-- this actually overrides automatically applied profiles
-- like 'protocol.http'
if state == 0 then
mp.set_property("profile", lqprofile)
mp.msg.info("[quality] running battery, setting low-quality options.")
mp.osd_message("[quality] LQ")
else
mp.set_property("profile", hqprofile)
mp.msg.info("[quality] running ac, setting high-quality options.")
mp.osd_message("[quality] HQ")
end
local state = powerstate()
-- this actually overrides automatically applied profiles
-- like 'protocol.http'
if state == 0 then
mp.set_property("profile", lqprofile)
mp.msg.info("[quality] running battery, setting low-quality options.")
mp.osd_message("[quality] LQ")
else
mp.set_property("profile", hqprofile)
mp.msg.info("[quality] running ac, setting high-quality options.")
mp.osd_message("[quality] HQ")
end
end
mp.add_hook("on_load", 1, adjust)