From 67dce9601ce243c9121422a300d88ba78389b78e Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Thu, 29 Oct 2009 20:50:25 +0100 Subject: [PATCH] More generic code. Signed-off-by: Pierre Habouzit --- config/awesome/rc.lua | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index d2ea01d..8df6ac9 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -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 -- }}} -- 2.20.1