Debian Codegraph @

obvious/lib/widget/progressbar.lua

raw symbols SCIP
1 -----------------------------------
2 -- Author: Uli Schlachter --
3 -- Copyright 2009 Uli Schlachter --
4 -----------------------------------
5
6 local beautiful = require("beautiful")
7 local awful = {
8 widget = require("awful.widget")
9 }
10
11 local function progressbar(layout)
12 local theme = beautiful.get()
13 local width = theme.progressbar_width or theme.widget_width or 8
14 local color = theme.progressbar_fg_color or theme.widget_fg_color or theme.fg_normal
15 local back = theme.progressbar_bg_color or theme.widget_bg_color or theme.bg_normal
16 local border= theme.progressbar_border or theme.widget_border or theme.border_normal
17
18 local widget = awful.widget.progressbar({ layout = layout })
19 widget:set_vertical(true)
20
21 widget:set_width(width)
22 widget:set_color(color)
23 widget:set_background_color(back)
24 widget:set_border_color(border)
25
26 return widget
27 end
28
29 local function create(data, layout)
30 local widget = progressbar(layout)
31
32 widget.update = function(widget)
33 -- TODO: We don't support data sources without a fixed upper bound
34 local max = widget.data.max or 1
35 local val = widget.data:get() or max
36 widget:set_value(val / max)
37 end
38
39 widget.data = data
40
41 return widget
42 end
43
44 return setmetatable({
45 }, { __call = function (_, ...) return progressbar(...) end })
46
47 -- vim:ft=lua:ts=2:sw=2:sts=2:tw=80:et