-- Include awesome library, with lots of useful function!
require("awful")
require("eminent")
-require("wicked")
+require("vicious")
require("beautiful")
terminal = "x-terminal-emulator"
-- }}}
-- {{{ Widgets
--- {{{ Load Averages Widget
+-- {{{ Load Average Widget
-loadwidget = widget({
- type = 'textbox',
- name = 'gpuwidget',
- align = 'right'
-})
-
-wicked.register(loadwidget, 'function', function (widget, args)
+loadwidget = widget({ type = 'textbox' })
+load_update = function()
-- Use /proc/loadavg to get the average system load on 1, 5 and 15 minute intervals
local f = io.open('/proc/loadavg')
local n = f:read()
-- Find the third space
local pos = n:find(' ', n:find(' ', n:find(' ')+1)+1)
- return heading('Load')..': '..n:sub(1,pos-1)
+ loadwidget.text = heading('Load')..': '..n:sub(1,pos-1)
+end
+load_update()
-end, 2)
+t = timer { timeout = 10 }
+t:add_signal("timeout", load_update)
+t:start()
-- }}}
-- {{{ CPU Usage Widget
-cputextwidget = widget({
- type = 'textbox',
- name = 'cputextwidget',
- align = 'right'
-})
-
-cputextwidget.text = heading('CPU')..': 00% '
-wicked.register(cputextwidget, 'cpu', function (widget, args)
+cputextwidget = widget({ type = 'textbox' })
+cpugraphwidget = awful.widget.graph{
+ width = 40, height = 16,
+ layout = awful.widget.layout.horizontal.rightleft
+}
+cpugraphwidget:set_background_color('#333333')
+cpugraphwidget:set_border_color('#0a0a0a')
+cpugraphwidget:set_gradient_colors({ '#285577', '#285577', '#AEC6D8' })
+
+vicious.register(cputextwidget, vicious.widgets.cpu,
+function (widget, args)
local r = tonumber(args[1])
local percent = args[1]..'%'
if r < 10 then
else
percent = fg('red', percent)
end
+ cpugraphwidget:add_value(r / 100)
return heading('CPU')..': '..percent..' '
end, 2)
-- }}}
-- {{{ CPU Graph Widget
-cpugraphwidget = widget({
- type = 'graph',
- name = 'cpugraphwidget',
- align = 'right'
-})
-
-cpugraphwidget.height = 0.85
-cpugraphwidget.width = 45
-cpugraphwidget.bg = '#333333'
-cpugraphwidget.border_color = '#0a0a0a'
-cpugraphwidget.grow = 'right'
-
-cpugraphwidget:plot_properties_set('cpu', {
- fg = '#AEC6D8',
- fg_center = '#285577',
- fg_end = '#285577',
- vertical_gradient = false
-})
-
-wicked.register(cpugraphwidget, 'cpu', '$1', 2, 'cpu')
-
-- }}}
-- {{{ Memory Usage Widget
-memtextwidget = widget({
- type = 'textbox',
- name = 'memtextwidget',
- align = 'right'
-})
+memtextwidget = widget({ type = 'textbox' })
memtextwidget.text = heading('MEM')..': '
-wicked.register(memtextwidget, 'mem', function (widget, args)
+vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args)
-- Add extra preceding zeroes when needed
local r = tonumber(args[1])
local percent = args[1]..'%'
return heading('MEM')..': '..percent..' '..args[2]..'M'
end, 2)
--- }}}
--- {{{ Battery widget
---[[
-batterywidget = widget({
- type = 'textbox',
- name = 'batterywidget',
- align = 'right'
-})
-
-function batterywidget_update()
- local v = io.popen("powersave -b|sed -ne 's/.*Remaining percent: \\(.*\\)/\\1/p'"):read()
- local r = tonumber(v)
-
- percent = v
- if r < 10 then
- percent = fg('red', percent)
- elseif r < 25 then
- percent = fg('orange', percent)
- else
- percent = fg('green', percent)
- end
- batterywidget.text = heading('BAT')..': '..percent
-end
-batterywidget_update()
-awful.hooks.timer.register(30, batterywidget_update)
---]]
-- }}}
-- {{{ spacers
-rspacer = widget({ type = 'textbox', name = 'rspacer', align = 'right' })
+rspacer = widget({ type = 'textbox' })
rspacer.text = " │ "
-- }}}
-- {{{ Clock
-clockwidget = widget({ type = "textbox", name = "clockwidget", align = "right" })
-clock_update = function()
- clockwidget.text = fg("#dddddd", os.date("%a %d %b - %H:%M"))
-end
-clock_update()
-awful.hooks.timer.register(10, clock_update)
+
+clockwidget = widget({ type = "textbox" })
+vicious.register(clockwidget, vicious.widgets.date, fg("#dddddd", "%a %d %b - %H:%M"), 10)
-- }}}
-mymenubox = widget{ type = "textbox", name = "mytextbox", align = "left" }
+mymenubox = widget{ type = "textbox" }
-- {{{ Statusbar
mainstatusbar = {}
for s = 1, screen.count() do
- mainstatusbar[s] = wibox{
- position = "top",
- height = 18,
- name = "mainstatusbar" .. s,
- }
+ mainstatusbar[s] = awful.wibox{ position = "top", height = 18, screen = s }
mainstatusbar[s].widgets = {
- awful.widget.taglist.new(s, awful.widget.taglist.label.noempty, maintaglist.buttons),
- maintaglist,
- mymenubox,
-
- rspacer, loadwidget,
- rspacer, cputextwidget, cpugraphwidget,
- rspacer, memtextwidget,
- rspacer, clockwidget,
+ {
+ awful.widget.taglist(s, awful.widget.taglist.label.noempty, maintaglist.buttons),
+ maintaglist,
+ awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }),
+ layout = awful.widget.layout.horizontal.leftright
+ },
+ clockwidget, rspacer,
+ memtextwidget, rspacer,
+ cpugraphwidget, cputextwidget, rspacer,
+ loadwidget, rspacer,
+ layout = awful.widget.layout.horizontal.rightleft
}
- mainstatusbar[s].screen = s
end
-- }}}
awful.prompt.run({ prompt = "Run: " },
mymenubox,
awful.util.spawn,
- awful.completion.bash,
+ awful.completion.shell,
awful.util.getdir("cache").."/commands")
end),
awful.key(k_m, "F4",
awful.prompt.run({ prompt = "Run Lua code: " },
mymenubox,
awful.util.eval,
- awful.prompt.bash,
+ awful.prompt.shell,
awful.util.getdir("cache").."/lua_commands")
end),
root.keys(globalkeys)
-- }}}
--- {{{ Hooks
+-- {{{ signals
-awful.hooks.focus.register(function (c)
+client.add_signal("focus", function (c)
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_focus
end
end)
-awful.hooks.unfocus.register(function (c)
+client.add_signal("unfocus", function (c)
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_normal
end
end)
-awful.hooks.marked.register(function (c)
+client.add_signal("marked", function (c)
c.border_color = beautiful.border_marked
end)
-awful.hooks.unmarked.register(function (c)
+client.add_signal("unmarked", function (c)
c.border_color = beautiful.border_focus
end)
--- Hook function to execute when the mouse enters a client.
-awful.hooks.mouse_enter.register(function (c)
- -- Sloppy focus
- client.focus = c
-end)
-
-awful.hooks.manage.register(function (c, startup)
+client.add_signal("manage", function (c, startup)
if not startup and awful.client.focus.filter(c) then
c.screen = mouse.screen
end
awful.button(k_a, 3, awful.mouse.client.resize)
))
+ -- Enable sloppy focus
+ c:add_signal("mouse::enter", function(c)
+ client.focus = c
+ end)
+
-- Create border
c.border_width = beautiful.border_width
c.border_color = beautiful.border_normal
-- Hook function to execute when arranging the screen
-- (tag switch, new client, etc)
-awful.hooks.arrange.register(function (screen)
+client.add_signal("arrange", function (screen)
local sel = client.focus
if not sel then