2009-09-29 22:33:19 +02:00
|
|
|
---------------------------------------------------
|
|
|
|
-- Licensed under the GNU General Public License v2
|
2010-01-02 21:21:54 +01:00
|
|
|
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
2009-09-29 22:33:19 +02:00
|
|
|
---------------------------------------------------
|
2009-08-06 02:26:23 +02:00
|
|
|
|
|
|
|
-- {{{ Grab environment
|
2009-10-26 20:32:48 +01:00
|
|
|
local tonumber = tonumber
|
2019-06-22 13:12:37 +02:00
|
|
|
|
|
|
|
local helpers = require"vicious.helpers"
|
|
|
|
local spawn = require"vicious.spawn"
|
2009-08-06 02:26:23 +02:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
|
|
|
|
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
2012-06-15 18:07:05 +02:00
|
|
|
-- vicious.widgets.hddtemp
|
2019-06-22 13:12:37 +02:00
|
|
|
return helpers.setasyncall{
|
|
|
|
async = function(format, warg, callback)
|
|
|
|
if warg == nil then warg = 7634 end -- fallback to default hddtemp port
|
|
|
|
local hdd_temp = {} -- get info from the hddtemp daemon
|
|
|
|
spawn.with_line_callback_with_shell(
|
|
|
|
"echo | curl -fs telnet://127.0.0.1:" .. warg,
|
|
|
|
{ stdout = function (line)
|
|
|
|
for d, t in line:gmatch"|([%/%w]+)|.-|(%d+)|[CF]|" do
|
|
|
|
hdd_temp["{"..d.."}"] = tonumber(t)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
output_done = function () callback(hdd_temp) end })
|
|
|
|
end }
|