123456789101112131415161718192021 |
- local wibox = require("wibox")
- local awful = require("awful")
- battery_widget = wibox.widget.textbox()
- battery_widget:set_align("right")
- function update_battery(widget)
- local cmd = "acpi | awk '{if($1 == \"Battery\"){print substr( $4, 1, length($4) - 1 )}}'"
- local fd = io.popen(cmd)
- local status = fd:read("*l")
- fd:close()
- widget:set_markup("B: "..status)
- end
- update_battery(battery_widget)
- mytimer = timer({ timeout = 10 })
- mytimer:connect_signal("timeout", function () update_battery(battery_widget) end)
- mytimer:start()
|