]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge pull request #16 from yawnt/brightness
authorLuke Bonham <copycat-killer@users.noreply.github.com>
Mon, 23 Dec 2013 16:59:23 +0000 (08:59 -0800)
committerLuke Bonham <copycat-killer@users.noreply.github.com>
Mon, 23 Dec 2013 16:59:23 +0000 (08:59 -0800)
contrib-widget: brightness

widgets/contrib/brightness.lua [new file with mode: 0644]

diff --git a/widgets/contrib/brightness.lua b/widgets/contrib/brightness.lua
new file mode 100644 (file)
index 0000000..6967572
--- /dev/null
@@ -0,0 +1,43 @@
+
+--[[
+
+     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 string          = { match  = string.match }
+
+local setmetatable    = setmetatable
+
+-- Brightness
+-- 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 })