base: update subfuction added; contrib/brightness removed because now redundant
This commit is contained in:
parent
8147032a53
commit
377b316f5d
3 changed files with 8 additions and 47 deletions
|
@ -12,7 +12,7 @@ local wibox = require("wibox")
|
||||||
local io = io
|
local io = io
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Basic template for simple widgets
|
-- Basic template for custom widgets
|
||||||
-- lain.widgets.base
|
-- lain.widgets.base
|
||||||
local base = {}
|
local base = {}
|
||||||
|
|
||||||
|
@ -24,14 +24,17 @@ local function worker(args)
|
||||||
|
|
||||||
base.widget = wibox.widget.textbox('')
|
base.widget = wibox.widget.textbox('')
|
||||||
|
|
||||||
function update()
|
function base.update()
|
||||||
output = io.popen(cmd):read("*all")
|
local f = assert(io.popen(cmd))
|
||||||
|
output = f:read("*all")
|
||||||
|
f:close()
|
||||||
widget = base.widget
|
widget = base.widget
|
||||||
settings()
|
settings()
|
||||||
end
|
end
|
||||||
|
|
||||||
newtimer(cmd, timeout, update)
|
newtimer(cmd, timeout, update)
|
||||||
return base.widget
|
|
||||||
|
return setmetatable(base, { __index = base.widget })
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(base, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(base, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
|
|
||||||
--[[
|
|
||||||
|
|
||||||
Licensed under GNU General Public License v2
|
|
||||||
* (c) 2013, yawnt <yawn.localhost@gmail.com>
|
|
||||||
|
|
||||||
--]]
|
|
||||||
|
|
||||||
local newtimer = require("lain.helpers").newtimer
|
|
||||||
|
|
||||||
local wibox = require("wibox")
|
|
||||||
local io = { popen = io.popen }
|
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
|
|
||||||
-- Brightness level
|
|
||||||
-- 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"))
|
|
||||||
brightness_now = f:read("*a")
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
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 })
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit 60754084cf7bb69d7387484e12fa686c73cfe1bc
|
Subproject commit b56a779e276987cb9f8f8d81785d35633db047d1
|
Loading…
Add table
Reference in a new issue