]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

fix custom widgets for 3.4
authormartin f. krafft <madduck@madduck.net>
Sat, 31 Oct 2009 19:09:44 +0000 (19:09 +0000)
committermartin f. krafft <madduck@madduck.net>
Sat, 31 Oct 2009 19:18:31 +0000 (19:18 +0000)
.config/awesome/rc.lua

index bb286438d7bd35007fac78c1d898f5c8db351b13..0fbd3b6354bd29d672041798e4de3527c268f18b 100644 (file)
@@ -132,6 +132,8 @@ mytextclock = awful.widget.textclock({ align = "right" })
 -- Create a systray
 mysystray = widget({ type = "systray" })
 
 -- Create a systray
 mysystray = widget({ type = "systray" })
 
+mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
+
 -- Create a wibox for each screen and add it
 mywibox = {}
 mypromptbox = {}
 -- Create a wibox for each screen and add it
 mywibox = {}
 mypromptbox = {}
@@ -202,7 +204,8 @@ for s = 1, screen.count() do
         },
         mylayoutbox[s],
         mytextclock,
         },
         mylayoutbox[s],
         mytextclock,
-        s == 1 and mysystray or nil,
+        mybatterybox,
+        s == screen.count() and mysystray or nil,
         mytasklist[s],
         layout = awful.widget.layout.horizontal.rightleft
     }
         mytasklist[s],
         layout = awful.widget.layout.horizontal.rightleft
     }
@@ -409,9 +412,19 @@ awful.rules.rules = {
       properties = { floating = true } },
     { rule = { class = "gimp" },
       properties = { floating = true } },
       properties = { floating = true } },
     { rule = { class = "gimp" },
       properties = { floating = true } },
+    { rule = { class = "twinkle" },
+      properties = { floating = true } },
+    { rule = { class = "Play stream" },
+      properties = { floating = true } },
+    { rule = { class = "gscan2pdf" },
+      properties = { floating = true } },
+    { rule = { class = "Add-ons" },
+      properties = { floating = true } },
     -- Set Firefox to always map on tags number 2 of screen 1.
     -- Set Firefox to always map on tags number 2 of screen 1.
-    -- { rule = { class = "Firefox" },
-    --   properties = { tag = tags[1][2] } },
+    { rule = { class = "Firefox" },
+      properties = { tag = tags[1][9] } },
+    { rule = { class = "-v" },
+      properties = { tag = tags[1][8] } },
 }
 -- }}}
 
 }
 -- }}}
 
@@ -444,6 +457,55 @@ end)
 
 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
 
 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
+
+-- Hook called every second
+awful.hooks.timer.register(1, function ()
+    mytextclock.text = os.date(" %a %d %b %H:%M:%S ")
+end)
+
+-- Hook called every sixty seconds
+function hook_battery()
+    mybatterybox.text = " " .. get_acpibatt() .. " "
+end
+
+-- {{{ Statusbar battery
+--
+function get_acpibatt()
+
+    local f = io.popen('acpi -b', 'r')
+    if not f then
+      return "acpi -b failed"
+    end
+
+    local s = f:read('*l')
+    f:close()
+    if not s then
+      return '-';
+    end
+
+    -- Battery 0: Discharging, 89%, 00:02:14 remaining
+    -- Battery 0: Charging, 58%, 00:02:14 until charged
+    -- Battery 0: Full, 100%
+    -- so find the first bit first and then go look for the time
+    local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
+    local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
+
+    if not status or not percent then -- time can be empty if we're full
+      return "couldn't parse line " .. s
+    end
+
+    if not time then
+      return percent
+    end
+
+    if status == 'Charging' then
+      return '↑ ' .. percent;
+    elseif status == 'Discharging' then
+      return '↓ '.. time;
+    else
+      return '';
+    end
+end
 -- }}}
 
 --{{{ batt hook
 -- }}}
 
 --{{{ batt hook