More generic code.
authorPierre Habouzit <madcoder@debian.org>
Thu, 29 Oct 2009 19:50:25 +0000 (20:50 +0100)
committerPierre Habouzit <madcoder@debian.org>
Thu, 29 Oct 2009 19:57:04 +0000 (20:57 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
config/awesome/rc.lua

index d2ea01d..8df6ac9 100644 (file)
@@ -196,6 +196,8 @@ function make_icon(fname, left, right, h, bg)
     return ib
 end
 
+local mywidgets = {}
+
 -- {{{ Taglist
 
 maintaglist = {}
@@ -215,7 +217,7 @@ mypromptbox = awful.widget.prompt{
 -- }}}
 -- {{{ CPU Widgets
 
-cpuicon = make_icon('cpu.png', 16, 4, 16)
+table.insert(mywidgets, make_icon('cpu.png', 16, 4, 16))
 
 cputextwidget = widget({ type = 'textbox' })
 
@@ -238,10 +240,12 @@ function (widget, args)
     return percent..' '
 end, 2)
 
+table.insert(mywidgets, cputextwidget)
+
 -- }}}
 -- {{{ Memory Usage Widget
 
-memicon = make_icon('mem.png', 16, 4, 16)
+table.insert(mywidgets, make_icon('mem.png', 16, 4, 16))
 
 memtextwidget = widget({ type = 'textbox' })
 
@@ -262,37 +266,39 @@ vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args)
     return percent..' '..args[2]..'M'
 end, 2)
 
+table.insert(mywidgets, memtextwidget)
+
 -- }}}
 -- {{{ Clock
 
-clockicon = make_icon('clock.png', 16, 4, 16)
+table.insert(mywidgets, make_icon('clock.png', 16, 4, 16))
 
 clockwidget = widget({ type = "textbox" })
 vicious.register(clockwidget, vicious.widgets.date,
                  fg(theme.fg_focus, "%H:%M") .. " %a %d %b  ", 10)
 
+table.insert(mywidgets, clockwidget)
+
 -- }}}
 -- {{{ Statusbar
 
-mainstatusbar = {}
 for s = 1, screen.count() do
-    local lr_layout = awful.widget.layout.horizontal.leftright
-    local rl_layout = awful.widget.layout.horizontal.rightleft
-
-    mainstatusbar[s] = awful.wibox{ position = "top", height = 16, screen = s }
-
-    mainstatusbar[s].widgets = {
+    local tab = {
         {
             awful.widget.taglist(s, maintaglist.label, maintaglist.buttons),
             mypromptbox.widget,
-            layout = lr_layout
+            layout = awful.widget.layout.horizontal.leftright
         },
-        s == 1 and widget{ type = 'systray' } or nil,
-        clockwidget, clockicon,
-        memtextwidget, memicon,
-        cputextwidget, cpuicon,
-        layout = awful.widget.layout.horizontal.rightleft
     }
+
+    if (s == 1) then
+        table.insert(tab, widget{ type = 'systray' })
+    end
+    for i = #mywidgets, 1, -1 do
+        table.insert(tab, mywidgets[i])
+    end
+    tab["layout"] = awful.widget.layout.horizontal.rightleft
+    awful.wibox{ position = "top", height = 16, screen = s }.widgets = tab
 end
 
 -- }}}