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

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:

tpbat wiki entry added
[etc/awesome.git] / widgets / borderbox.lua
1
2 --[[
3                                                   
4      Licensed under GNU General Public License v2 
5       * (c) 2013,      Luke Bonham                
6       * (c) 2010-2012, Peter Hofmann              
7                                                   
8 --]]
9
10 local wibox        = require("awful.wibox")
11 local setmetatable = setmetatable
12
13 -- Creates a thin wibox at a position relative to another wibox
14 -- lain.widgets.borderbox
15 local borderbox = {}
16
17 local function worker(relbox, s, args)
18     local where = args.position or 'top'
19     local color = args.color or '#FFFFFF'
20     local size = args.size or 1
21     local box = nil
22     local wiboxarg = {
23         position = nil,
24         bg = color
25     }
26
27     if where == 'top'
28     then
29         wiboxarg.width = relbox.width
30         wiboxarg.height = size
31         box = wibox(wiboxarg)
32         box.x = relbox.x
33         box.y = relbox.y - size
34     elseif where == 'bottom'
35     then
36         wiboxarg.width = relbox.width
37         wiboxarg.height = size
38         box = wibox(wiboxarg)
39         box.x = relbox.x
40         box.y = relbox.y + relbox.height
41     elseif where == 'left'
42     then
43         wiboxarg.width = size
44         wiboxarg.height = relbox.height
45         box = wibox(wiboxarg)
46         box.x = relbox.x - size
47         box.y = relbox.y
48     elseif where == 'right'
49     then
50         wiboxarg.width = size
51         wiboxarg.height = relbox.height
52         box = wibox(wiboxarg)
53         box.x = relbox.x + relbox.width
54         box.y = relbox.y
55     end
56
57     box.screen = s
58     return box
59 end
60
61 return setmetatable(borderbox, { __call = function(_, ...) return worker(...) end })