]> 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:

base widget added (this time for real)
authorluke bonham <dadasignificanulla@gmail.com>
Thu, 13 Feb 2014 16:35:55 +0000 (17:35 +0100)
committerluke bonham <dadasignificanulla@gmail.com>
Thu, 13 Feb 2014 16:35:55 +0000 (17:35 +0100)
widgets/base.lua [new file with mode: 0644]

diff --git a/widgets/base.lua b/widgets/base.lua
new file mode 100644 (file)
index 0000000..0431d03
--- /dev/null
@@ -0,0 +1,37 @@
+
+--[[
+                                                  
+     Licensed under GNU General Public License v2 
+      * (c) 2014, Luke Bonham                     
+                                                  
+--]]
+
+local newtimer     = require("lain.helpers").newtimer
+local wibox        = require("wibox")
+
+local io           = io
+local setmetatable = setmetatable
+
+-- Basic template for simple widgets 
+-- lain.widgets.base
+local base = {}
+
+local function worker(args)
+    local args     = args or {}
+    local timeout  = args.timeout or 5
+    local cmd      = args.cmd or ""
+    local settings = args.settings or function() end
+
+    base.widget = wibox.widget.textbox('')
+
+    function update()
+        output = io.popen(cmd):read("*all")
+        widget = base.widget
+        settings()
+    end
+
+    newtimer(cmd, timeout, update)
+    return base.widget
+end
+
+return setmetatable(base, { __call = function(_, ...) return worker(...) end })