-- 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 = {}
},
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
}
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.
- -- { rule = { class = "Firefox" },
- -- properties = { tag = tags[1][2] } },
+ { rule = { class = "Firefox" },
+ properties = { tag = tags[1][9] } },
+ { rule = { class = "-v" },
+ properties = { tag = tags[1][8] } },
}
-- }}}
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