require("awful")
require("awful.autofocus")
require("awful.rules")
-require("vicious")
require("beautiful")
+require("vicious")
-terminal = "x-terminal-emulator"
+terminal = "urxvtcd"
lock = 'xscreensaver-command -lock'
beautiful.init(awful.util.getdir("config").."/theme")
-- {{{ Modkeys
-modkey = "Mod4"
-shift = "Shift"
-alt = "Mod1"
+modkey = "Mod4"
+shift = "Shift"
+alt = "Mod1"
control = "Control"
k_n = {}
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
-- }}}
-- {{{ CPU Widgets
-table.insert(mywidgets, 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, 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
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)
awful.key(k_ms, "k", function () awful.client.swap.byidx(-1) end),
-- Mod+{E/D}: Switch to next/previous screen
- awful.key(k_m, "Tab", function () awful.screen.focus_relative(1) end),
- awful.key(k_ms, "Tab", function () awful.screen.focus_relative(-1) end),
+ awful.key(k_m, "Tab", function ()
+ awful.screen.focus_relative(1)
+ coords = mouse.coords();
+ mouse.coords({ x = coords.x + 5, y = coords.y + 5}, true)
+ end),
+ awful.key(k_ms, "Tab", function ()
+ awful.screen.focus_relative(-1)
+ coords = mouse.coords()
+ mouse.coords({ x = coords.x + 5, y = coords.y + 5}, true)
+ end),
-- Mod+Enter: Launch a new terminal
- awful.key(k_m, "e", function() awful.util.spawn("firefox") end),
+ awful.key(k_m, "e", function() awful.util.spawn("chromium-browser") end),
awful.key(k_m, "Return", function() awful.util.spawn(terminal) end),
awful.key(k_ac, "r", awesome.restart),
awful.key(k_m, "F12", function() awful.util.spawn(lock) end),
-- }}}
-- {{{ Signals
-function warp_mouse(c)
- local o = awful.mouse.client_under_pointer()
- if not o or o ~= c then
- local g = c:geometry()
- mouse.coords({ x = g.x + 5, y = g.y + 5 }, true)
- end
-end
-
client.add_signal("focus", function (c)
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_focus
end
- warp_mouse(c)
end)
client.add_signal("unfocus", function (c)
c:add_signal("mouse::enter", function(c) client.focus = c end)
end)
-for s = 1, screen.count() do
- screen[s]:add_signal("arrange", function ()
- if client.focus and client.focus.screen == s then
- warp_mouse(client.focus)
- end
- end)
-end
-
-- }}}
awful.util.spawn("xkbcomp -w 0 -R/usr/share/X11/xkb /home/madcoder/.Xkeyboard :0")