Gizmoguy's super-easy acpi battery widget

Just hacked this together as no other battery widget did what I wanted and was nice and simple. You will need acpiclient for this to work.

-- Create an ACPI widget batterywidget = widget({ type = "textbox" }) batterywidget.text = " | Battery | " batterywidgettimer = timer({ timeout = 5 }) batterywidgettimer:add_signal("timeout",                                         function                                                                        fh = assert(io.popen("acpi | cut -d, -f 2,3 -", "r"))                           batterywidget.text = " |" .. fh:read("*l") .. " | "                             fh:close                                                                    end                                                                           ) batterywidgettimer:start

Basically all this does is pipe 'acpi' through a 'cut' to clean it up a bit, every 5 seconds.

Remember to add to your wibox. No guarantee that this will keep working in the future.

Awesome 3.5 :

batterywidget = wibox.widget.textbox batterywidget:set_text(" | Battery | ") batterywidgettimer = timer({ timeout = 5 }) batterywidgettimer:connect_signal("timeout",     function        fh = assert(io.popen("acpi | cut -d, -f 2,3 -", "r"))        batterywidget:set_text(" |" .. fh:read("*l") .. " | ")       fh:close      end    ) batterywidgettimer:start