update awesomerc
authorPierre Habouzit <madcoder@debian.org>
Tue, 27 Oct 2009 17:14:14 +0000 (18:14 +0100)
committerPierre Habouzit <madcoder@debian.org>
Tue, 27 Oct 2009 17:14:14 +0000 (18:14 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
config/awesome/rc.lua

index 552b893..0d88625 100644 (file)
@@ -56,14 +56,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 +75,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 +83,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 +141,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 +185,21 @@ end
 -- }}}
 -- {{{ Widgets
 
+function make_imagebox(fname, w, h, bg)
+    local icon = image(fname)
+    local ib   = widget { type = 'imagebox' }
+    local i    = image.argb32(w, h, nil)
+
+    if not bg then bg = beautiful.bg_normal end
+
+    i:draw_rectangle(0, 0, w, h, true, bg)
+    i:insert(icon, math.floor((w - icon.width) / 2),
+             math.floor((h - icon.height) / 2))
+
+    ib.image = i
+    return ib
+end
+
 -- {{{ Taglist
 
 maintaglist = {}
@@ -197,6 +207,14 @@ 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
+
+-- }}}
+-- {{{ Prompt box
+
+mypromptbox = awful.widget.prompt{
+    layout = awful.widget.layout.horizontal.leftright
+}
 
 -- }}}
 -- {{{ Load Average Widget
@@ -220,9 +238,13 @@ t:add_signal("timeout", load_update)
 t:start()
 
 -- }}}
--- {{{ CPU Usage Widget
+-- {{{ CPU Widgets
+
+cpuiconwidget = nil
+--    make_imagebox(os.getenv("HOME")..'/tmp/famfamfam/computer.png', 18, 18)
 
 cputextwidget = widget({ type = 'textbox' })
+
 cpugraphwidget = awful.widget.graph{
     width  = 40, height = 16,
     layout = awful.widget.layout.horizontal.rightleft
@@ -247,16 +269,18 @@ function (widget, args)
     else
         percent = fg('red', percent)
     end
-    -- cpugraphwidget:add_value(r / 100)
-    return heading('CPU')..': '..percent..' '
+    for s = 1, screen.count() do
+        cpugraphwidget:add_value(r / 100)
+    end
+    return ' '..percent..' '
 end, 2)
 
--- }}}
--- {{{ CPU Graph Widget
-
 -- }}}
 -- {{{ Memory Usage Widget
 
+memiconwidget = nil
+--    make_imagebox(os.getenv("HOME")..'/tmp/famfamfam/bricks.png', 18, 18)
+
 memtextwidget = widget({ type = 'textbox' })
 
 memtextwidget.text = heading('MEM')..': '
@@ -274,7 +298,7 @@ vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args)
     else
         percent = fg('red', percent)
     end
-    return heading('MEM')..': '..percent..' '..args[2]..'M'
+    return ' '..percent..' '..args[2]..'M'
 end, 2)
 
 -- }}}
@@ -287,32 +311,32 @@ rspacer.text = " │ "
 -- {{{ Clock
 
 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("#dddddd", "%a %d %b - %H:%M"), 10)
 
 -- }}}
-
-mymenubox = widget{ type = "textbox" }
-
 -- {{{ Statusbar
 
 mainstatusbar = {}
 mysystray = widget({ type = "systray" })
 
 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 = 18, 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,
+        memtextwidget, memiconwidget, rspacer,
+        cpugraphwidget.widget, cputextwidget, cpuiconwidget, rspacer,
         loadwidget, rspacer,
         layout = awful.widget.layout.horizontal.rightleft
     }
@@ -335,12 +359,12 @@ 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
+       local s = mouse.screen + 1
        while s > screen.count() do s = s - screen.count() end
        client.focus.screen = s
     end),
     awful.key(k_mc, "Left", function()
-       local s = getscreen() - 1
+       local s = mouse.screen - 1
        while s < 1 do s = s + screen.count() end
        client.focus.screen = s
     end),
@@ -382,20 +406,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 +452,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),