X-Git-Url: http://git.madism.org/?p=~madcoder%2Fdotfiles.git;a=blobdiff_plain;f=config%2Fawesome%2Frc.lua;h=5a838cad2f12416336997ab543ea60c03b121159;hp=d79b75d9d8a58ae4a5230ee79419c0a51150d446;hb=277a790c8aff8c308ac7acb38c7e4b7e977eb5f3;hpb=9dd2406c6615d9ef988f8449a0c64c67fab6ad4c diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index d79b75d..5a838ca 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -3,7 +3,7 @@ -- Include awesome library, with lots of useful function! require("awful") require("eminent") -require("wicked") +require("vicious") require("beautiful") terminal = "x-terminal-emulator" @@ -80,15 +80,10 @@ maintaglist.buttons = awful.util.table.join( -- }}} -- {{{ 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() @@ -97,21 +92,28 @@ wicked.register(loadwidget, 'function', function (widget, args) -- 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 @@ -126,44 +128,20 @@ wicked.register(cputextwidget, 'cpu', function (widget, args) 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]..'%' @@ -180,73 +158,42 @@ wicked.register(memtextwidget, 'mem', function (widget, args) 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 -- }}} @@ -329,7 +276,7 @@ globalkeys = awful.util.table.join( 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", @@ -337,7 +284,7 @@ globalkeys = awful.util.table.join( awful.prompt.run({ prompt = "Run Lua code: " }, mymenubox, awful.util.eval, - awful.prompt.bash, + awful.prompt.shell, awful.util.getdir("cache").."/lua_commands") end), @@ -397,35 +344,29 @@ clientkeys = awful.util.table.join( 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 @@ -437,6 +378,11 @@ awful.hooks.manage.register(function (c, startup) 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 @@ -458,7 +404,7 @@ end) -- 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