]> git.madduck.net Git - etc/awesome.git/blob - widgets/base.lua.orig

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:

Delete asyncshell_REMOTE_32072.lua
[etc/awesome.git] / widgets / base.lua.orig
1
2 --[[
3                                                   
4      Licensed under GNU General Public License v2 
5       * (c) 2014, Luke Bonham                     
6                                                   
7 --]]
8
9 local newtimer     = require("lain.helpers").newtimer
10 <<<<<<< HEAD
11 local wibox        = require("wibox")
12
13 local io           = { popen = io.popen }
14 =======
15 local read_pipe    = require("lain.helpers").read_pipe
16
17 local wibox        = require("wibox")
18
19 >>>>>>> upstream/master
20 local setmetatable = setmetatable
21
22 -- Basic template for custom widgets
23 -- lain.widgets.base
24
25 local function worker(args)
26     local base     = {}
27     local args     = args or {}
28     local timeout  = args.timeout or 5
29     local cmd      = args.cmd or ""
30     local settings = args.settings or function() end
31
32     base.widget = wibox.widget.textbox('')
33
34     function base.update()
35 <<<<<<< HEAD
36         local f = assert(io.popen(cmd))
37         output = f:read("*a")
38         f:close()
39 =======
40         output = read_pipe(cmd)
41 >>>>>>> upstream/master
42         widget = base.widget
43         settings()
44     end
45
46     newtimer(cmd, timeout, base.update)
47
48     return setmetatable(base, { __index = base.widget })
49 end
50
51 return setmetatable({}, { __call = function(_, ...) return worker(...) end })