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

Delete asyncshell_BACKUP_1080.lua
[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
12 local setmetatable = setmetatable
13
14 -- Creates a thin wibox at a position relative to another wibox
15 -- lain.widgets.borderbox
16 local borderbox = {}
17
18 local function worker(relbox, s, args)
19     local where = args.position or 'top'
20     local color = args.color or '#FFFFFF'
21     local size = args.size or 1
22     local box = nil
23     local wiboxarg = {
24         position = nil,
25         bg = color
26     }
27
28     if where == 'top'
29     then
30         wiboxarg.width = relbox.width
31         wiboxarg.height = size
32         box = wibox(wiboxarg)
33         box.x = relbox.x
34         box.y = relbox.y - size
35     elseif where == 'bottom'
36     then
37         wiboxarg.width = relbox.width
38         wiboxarg.height = size
39         box = wibox(wiboxarg)
40         box.x = relbox.x
41         box.y = relbox.y + relbox.height
42     elseif where == 'left'
43     then
44         wiboxarg.width = size
45         wiboxarg.height = relbox.height
46         box = wibox(wiboxarg)
47         box.x = relbox.x - size
48         box.y = relbox.y
49     elseif where == 'right'
50     then
51         wiboxarg.width = size
52         wiboxarg.height = relbox.height
53         box = wibox(wiboxarg)
54         box.x = relbox.x + relbox.width
55         box.y = relbox.y
56     end
57
58     box.screen = s
59     return box
60 end
61
62 return setmetatable(borderbox, { __call = function(_, ...) return worker(...) end })