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

wiki updated; closes #236
[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 = { position = nil, bg = color }
23
24     if where == 'top'
25     then
26         wiboxarg.width = relbox.width
27         wiboxarg.height = size
28         box = wibox(wiboxarg)
29         box.x = relbox.x
30         box.y = relbox.y - size
31     elseif where == 'bottom'
32     then
33         wiboxarg.width = relbox.width
34         wiboxarg.height = size
35         box = wibox(wiboxarg)
36         box.x = relbox.x
37         box.y = relbox.y + relbox.height
38     elseif where == 'left'
39     then
40         wiboxarg.width = size
41         wiboxarg.height = relbox.height
42         box = wibox(wiboxarg)
43         box.x = relbox.x - size
44         box.y = relbox.y
45     elseif where == 'right'
46     then
47         wiboxarg.width = size
48         wiboxarg.height = relbox.height
49         box = wibox(wiboxarg)
50         box.x = relbox.x + relbox.width
51         box.y = relbox.y
52     end
53
54     box.screen = s
55     return box
56 end
57
58 return setmetatable(borderbox, { __call = function(_, ...) return worker(...) end })