From: martin f. krafft Date: Sat, 31 Oct 2009 19:09:44 +0000 (+0000) Subject: fix custom widgets for 3.4 X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/00a7eb61e6a493be23f18fa039e284e5118d42f7?hp=f44dc93752cdaec77f605651f57d542200808fbe fix custom widgets for 3.4 --- diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index bb28643..0fbd3b6 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -132,6 +132,8 @@ mytextclock = awful.widget.textclock({ align = "right" }) -- 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 = {} @@ -202,7 +204,8 @@ for s = 1, screen.count() do }, 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 } @@ -409,9 +412,19 @@ awful.rules.rules = { 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] } }, } -- }}} @@ -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) + +-- 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