Skip to content

Instantly share code, notes, and snippets.

@opqdonut
Created April 14, 2013 18:23
Show Gist options
  • Save opqdonut/5383677 to your computer and use it in GitHub Desktop.
Save opqdonut/5383677 to your computer and use it in GitHub Desktop.
-- statusd_mybatt.lua
--
-- Author
-- Joel Kaasinen
if not statusd_mybatt then
statusd_uptime={
interval=60*1000,
}
end
local timer = nil -- the timer
--
-- update the uptime monitor
--
local function get_mybatt_info()
local f=io.popen('acpi -b', 'r')
timer:set(statusd_uptime.interval, get_mybatt_info)
if not f then
statusd.inform("mybatt", "oops")
return
end
local s=f:read('*line')
f:close()
s = string.gsub(s, " remaining", "")
s = string.gsub(s, "Battery .: ", "")
statusd.inform("mybatt", s)
end
--
-- start the timer
--
local function init_uptime_monitor()
timer = statusd.create_timer()
statusd.inform("mybatt_template",
"Discharging, xx%, xx:xx:xx foobar")
get_mybatt_info()
end
init_uptime_monitor()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment