2013-12-23 17:19:25 +01:00
|
|
|
|
|
|
|
--[[
|
2013-12-23 18:04:06 +01:00
|
|
|
|
|
|
|
Licensed under GNU General Public License v2
|
2013-12-23 17:19:25 +01:00
|
|
|
* (c) 2013, yawnt <yawn.localhost@gmail.com>
|
2013-12-23 18:04:06 +01:00
|
|
|
|
2013-12-23 17:19:25 +01:00
|
|
|
--]]
|
|
|
|
|
|
|
|
local newtimer = require("lain.helpers").newtimer
|
|
|
|
|
|
|
|
local wibox = require("wibox")
|
|
|
|
local io = { popen = io.popen }
|
|
|
|
local string = { match = string.match }
|
|
|
|
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
|
2013-12-23 18:04:06 +01:00
|
|
|
-- Brightness
|
2013-12-23 17:19:25 +01:00
|
|
|
-- lain.widgets.contrib.brightness
|
|
|
|
local brightness = {}
|
|
|
|
|
|
|
|
local function worker(args)
|
|
|
|
local args = args or {}
|
|
|
|
local backlight = args.backlight or "acpi_video0"
|
|
|
|
local timeout = args.timeout or 5
|
|
|
|
local settings = args.settings or function() end
|
|
|
|
|
|
|
|
brightness.widget = wibox.widget.textbox('')
|
|
|
|
|
|
|
|
function brightness.update()
|
|
|
|
local f = assert(io.popen('cat /sys/class/backlight/' .. backlight .. "/brightness"))
|
2013-12-23 18:04:06 +01:00
|
|
|
brightness_now = f:read("*a")
|
2013-12-23 17:19:25 +01:00
|
|
|
f:close()
|
2013-12-23 18:04:06 +01:00
|
|
|
|
2013-12-23 17:19:25 +01:00
|
|
|
widget = brightness.widget
|
|
|
|
settings()
|
|
|
|
end
|
|
|
|
|
|
|
|
newtimer("brightness", timeout, brightness.update)
|
|
|
|
|
|
|
|
return setmetatable(brightness, { __index = brightness.widget })
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(brightness, { __call = function(_, ...) return worker(...) end })
|