X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=config%2Fawesome%2Frc.lua;h=d2ea01d5acaede6a4035e26d1d39ebf7c6b8295c;hb=3d04af67f10fdef9a11c86ec30c16c16ae8c1399;hp=552b8938a889942299849bd95881cb002f7a5107;hpb=07f46021d856344b5452a8ec6f4dd0c46e568f47;p=~madcoder%2Fdotfiles.git diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index 552b893..d2ea01d 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -37,10 +37,6 @@ function fg(color, text) return ''..text..'' end -function heading(text) - return fg(beautiful.fg_focus, text) -end - -- }}} -- {{{ Tags @@ -56,14 +52,9 @@ for s = 1, screen.count() do end -- Get the screen number we're on -function getscreen() - local sel = client.focus - return (sel and sel.screen) or mouse.screen -end - local mtag = { } function mtag.getn(idx, s) - return tags[s or getscreen()][idx] + return tags[s or mouse.screen][idx] end function mtag.viewonly (idx, s) local t = mtag.getn(idx, s) @@ -80,7 +71,7 @@ end function mtag.occupied(s) local p = {} - if not s then s = getscreen() end + if not s then s = mouse.screen end for t in pairs(tags[s]) do t = tags[s][t] if mtag.isoccupied(s, t) then table.insert(p, t) end @@ -88,7 +79,7 @@ function mtag.occupied(s) return p end function mtag.getnext(s) - if s == nil then s = getscreen() end + if s == nil then s = mouse.screen end local p = mtag.occupied(s) local curtag = awful.tag.selected() @@ -146,7 +137,7 @@ function mtag.movetonext(s) awful.tag.viewonly(t) end function mtag.getprev(s) - if s == nil then s = getscreen() end + if s == nil then s = mouse.screen end local p = mtag.occupied(s) local curtag = awful.tag.selected() @@ -190,6 +181,21 @@ end -- }}} -- {{{ Widgets +local icondir = awful.util.getdir("config").."/icons/" + +function make_icon(fname, left, right, h, bg) + local icon = image(icondir..fname) + local ib = widget { type = 'imagebox' } + local w = left + icon.width + right + local i = image.argb32(w, h, nil) + + i:draw_rectangle(0, 0, w, h, true, beautiful.bg_normal) + i:insert(icon, left, math.floor((h - icon.height) / 2)) + + ib.image = i + return ib +end + -- {{{ Taglist maintaglist = {} @@ -197,39 +203,21 @@ maintaglist.buttons = awful.util.table.join( awful.button(k_n, 1, awful.tag.viewonly), awful.button(k_s, 1, awful.client.toggletag) ) +maintaglist.label = awful.widget.taglist.label.noempty -- }}} --- {{{ Load Average Widget - -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() - f:close() - - -- Find the third space - local pos = n:find(' ', n:find(' ', n:find(' ')+1)+1) +-- {{{ Prompt box - loadwidget.text = heading('Load')..': '..n:sub(1,pos-1) -end -load_update() - -t = timer { timeout = 10 } -t:add_signal("timeout", load_update) -t:start() +mypromptbox = awful.widget.prompt{ + layout = awful.widget.layout.horizontal.leftright +} -- }}} --- {{{ CPU Usage Widget +-- {{{ CPU Widgets + +cpuicon = make_icon('cpu.png', 16, 4, 16) 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) @@ -239,27 +227,24 @@ function (widget, args) percent = '0'..percent end if r < 25 then - percent = fg('green', percent) + percent = fg(theme.fg_focus, percent) elseif r < 50 then percent = fg('yellow', percent) elseif r < 75 then percent = fg('orange', percent) else - percent = fg('red', percent) + percent = fg('#ff4040', percent) end - -- cpugraphwidget:add_value(r / 100) - return heading('CPU')..': '..percent..' ' + return percent..' ' end, 2) --- }}} --- {{{ CPU Graph Widget - -- }}} -- {{{ Memory Usage Widget +memicon = make_icon('mem.png', 16, 4, 16) + memtextwidget = widget({ type = 'textbox' }) -memtextwidget.text = heading('MEM')..': ' vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args) -- Add extra preceding zeroes when needed local r = tonumber(args[1]) @@ -268,52 +253,44 @@ vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args) percent = '0'..percent end if r < 50 then - percent = fg('green', percent) + percent = fg(theme.fg_focus, percent) elseif r < 80 then percent = fg('orange', percent) else percent = fg('red', percent) end - return heading('MEM')..': '..percent..' '..args[2]..'M' + return percent..' '..args[2]..'M' end, 2) --- }}} --- {{{ spacers - -rspacer = widget({ type = 'textbox' }) -rspacer.text = " │ " - -- }}} -- {{{ Clock +clockicon = make_icon('clock.png', 16, 4, 16) + clockwidget = widget({ type = "textbox" }) -vicious.register(clockwidget, vicious.widgets.date, fg("#dddddd", "%a %d %b - %H:%M"), 10) +vicious.register(clockwidget, vicious.widgets.date, + fg(theme.fg_focus, "%H:%M") .. " %a %d %b ", 10) -- }}} - -mymenubox = widget{ type = "textbox" } - -- {{{ Statusbar mainstatusbar = {} -mysystray = widget({ type = "systray" }) - for s = 1, screen.count() do - mainstatusbar[s] = awful.wibox{ position = "top", height = 18, screen = s } + 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 = { { - 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 + awful.widget.taglist(s, maintaglist.label, maintaglist.buttons), + mypromptbox.widget, + layout = lr_layout }, - s == 1 and mysystray or nil, - s == 1 and rspacer or nil, - clockwidget, rspacer, - memtextwidget, rspacer, - cpugraphwidget, cputextwidget, rspacer, - loadwidget, rspacer, + s == 1 and widget{ type = 'systray' } or nil, + clockwidget, clockicon, + memtextwidget, memicon, + cputextwidget, cpuicon, layout = awful.widget.layout.horizontal.rightleft } end @@ -323,7 +300,6 @@ end -- {{{ Keys ---- {{{ Global keys -local hist = os.getenv("HOME") .. "/.cache/awesome/history" globalkeys = awful.util.table.join( -- Mod+{A/S}: Switch to prev/next tag awful.key(k_m, "Left", mtag.prev), @@ -335,14 +311,10 @@ globalkeys = awful.util.table.join( -- Mod+Shift_{E/D}: move window to next/prev screen awful.key(k_mc, "Right", function() - local s = getscreen() + 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 = getscreen() - 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), @@ -382,20 +354,12 @@ globalkeys = awful.util.table.join( awful.key(k_mc, "l", function () awful.tag.incncol(-1) end), -- Menu - awful.key(k_m, "r", - function () - awful.prompt.run({ prompt = "Run: " }, - mymenubox, - awful.util.spawn, - awful.completion.shell, - awful.util.getdir("cache").."/commands") - end), + awful.key(k_m, "r", function () mypromptbox:run() end), awful.key(k_m, "F4", function () awful.prompt.run({ prompt = "Run Lua code: " }, - mymenubox, - awful.util.eval, - awful.prompt.shell, + mypromptbox.widget, + awful.util.eval, nil, awful.util.getdir("cache").."/lua_commands") end), @@ -436,10 +400,10 @@ end local clientkeys = awful.util.table.join( awful.key(k_m, "i", function (c) - if mymenubox.text then - mymenubox.text = "" + if mypromptbox.widget.text then + mypromptbox.widget.text = "" else - mymenubox.text = "Class: " .. c.class .. " Instance: ".. c.instance + mypromptbox.widget.text = "Class: " .. c.class .. " Instance: ".. c.instance end end), @@ -484,10 +448,19 @@ awful.rules.rules = { -- }}} -- {{{ 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) @@ -497,31 +470,18 @@ client.add_signal("unfocus", function (c) end) client.add_signal("manage", function (c, startup) - -- Enable sloppy focus - c:add_signal("mouse::enter", function(c) - client.focus = c - end) - - -- Focus new clients - client.focus = c + c:add_signal("mouse::enter", function(c) client.focus = c end) end) -function warp_mouse(screen) - local c = client.focus - - if c then - 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 } - end - end -end - for s = 1, screen.count() do - -- screen[s]:add_signal("arrange", warp_mouse) + 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") +awful.util.spawn("xsetroot -cursor_name left_ptr")