vicious/widgets/hddtemp_linux.lua

29 lines
1.0 KiB
Lua
Raw Normal View History

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
---------------------------------------------------
-- {{{ Grab environment
local tonumber = tonumber
2019-06-22 13:12:37 +02:00
local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
-- 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 }