return ib
end
+function draw_dashes_h(img, x, y, on, off, len, color)
+ for i = 0, len, on + off do
+ img:draw_line(x + i, y, x + i + on - 1, y, color)
+ end
+end
+
+function draw_dashes_v(img, x, y, on, off, len, color)
+ for i = 0, len, on + off do
+ img:draw_line(x, y + i, x, y + i + on - 1, color)
+ end
+end
+
+
+local mywidgets = {}
+
-- {{{ Taglist
maintaglist = {}
-- }}}
-- {{{ CPU Widgets
-cpuicon = make_icon('cpu.png', 16, 4, 16)
+local cpuwidgets = {}
+for i = 1, io.popen("grep -c ^cpu /proc/stat"):read("*n") do
+ local cpu = {}
+
+ cpu.widget = widget{ type = 'imagebox' }
+ cpu.update = function(cpu, value)
+ local color
-cputextwidget = widget({ type = 'textbox' })
+ if value < 25 then
+ color = beautiful.fg_focus
+ elseif value < 50 then
+ color = 'yellow'
+ elseif value < 75 then
+ color = 'orange'
+ else
+ color = 'red'
+ end
+
+ if cpu.color == color then return end
+ local img = image.argb32(11, 16, nil)
+ draw_dashes_h(img, 0, 4, 2, 1, 7, color)
+ draw_dashes_h(img, 0, 11, 2, 1, 7, color)
+ draw_dashes_v(img, 0, 4, 2, 1, 7, color)
+ draw_dashes_v(img, 7, 4, 2, 1, 7, color)
+ img:draw_rectangle(2, 6, 4, 4, true, color)
+ cpu.widget.image = img
+ cpu.percent = value
+ end
+ table.insert(mywidgets, cpu.widget)
+ cpuwidgets[i] = cpu
+end
+
+cputextwidget = widget{ type = 'textbox' }
vicious.register(cputextwidget, vicious.widgets.cpu,
function (widget, args)
local r = tonumber(args[1])
local percent = args[1]..'%'
+
+ for i = 1, #args do
+ cpuwidgets[i]:update(args[i])
+ end
+
if r < 10 then
percent = '0'..percent
end
if r < 25 then
- percent = fg(theme.fg_focus, percent)
+ percent = fg(beautiful.fg_focus, percent)
elseif r < 50 then
percent = fg('yellow', percent)
elseif r < 75 then
percent = fg('orange', percent)
else
- percent = fg('#ff4040', percent)
+ percent = fg('red', percent)
end
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' })
+memtextwidget = widget{ type = 'textbox' }
vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args)
-- Add extra preceding zeroes when needed
percent = '0'..percent
end
if r < 50 then
- percent = fg(theme.fg_focus, percent)
+ percent = fg(beautiful.fg_focus, percent)
elseif r < 80 then
percent = fg('orange', percent)
else
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" })
+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
-- }}}
-- Mod+Shift_{E/D}: move window to next/prev screen
awful.key(k_mc, "Right", function()
- local s = mouse.screen + 1
- while s > screen.count() do s = s - screen.count() end
- client.focus.screen = s
+ client.focus.screen = awful.util.cycle(screen.count(), mouse.screen + 1)
end),
awful.key(k_mc, "Left", function()
- local s = mouse.screen - 1
- while s < 1 do s = s + screen.count() end
- client.focus.screen = s
+ client.focus.screen = awful.util.cycle(screen.count(), mouse.screen - 1)
end),