[hddtemp_linux] Deprecate io.popen
This commit is contained in:
parent
565d74cc8b
commit
0e7f5e5bcb
|
@ -18,7 +18,7 @@ Added:
|
||||||
Fixed:
|
Fixed:
|
||||||
|
|
||||||
- Deprecate the use of `io.popen` in following widgets:
|
- Deprecate the use of `io.popen` in following widgets:
|
||||||
* wifi_linux, wifiiw_linux, hwmontemp_linux
|
* wifi_linux, wifiiw_linux, hwmontemp_linux, hddtemp_linux
|
||||||
* bat_freebsd, mem_freebsd, net_freebsd
|
* bat_freebsd, mem_freebsd, net_freebsd
|
||||||
* volume, gmail, mdir, mpd, fs
|
* volume, gmail, mdir, mpd, fs
|
||||||
- [mpd] Lua 5.3 compatibility (for real this time); also correct a typo
|
- [mpd] Lua 5.3 compatibility (for real this time); also correct a typo
|
||||||
|
|
|
@ -5,36 +5,24 @@
|
||||||
|
|
||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local io = { popen = io.popen }
|
|
||||||
local setmetatable = setmetatable
|
local helpers = require"vicious.helpers"
|
||||||
local string = { gmatch = string.gmatch }
|
local spawn = require"vicious.spawn"
|
||||||
local helpers = require("vicious.helpers")
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
||||||
-- vicious.widgets.hddtemp
|
-- vicious.widgets.hddtemp
|
||||||
local hddtemp_linux = {}
|
return helpers.setasyncall{
|
||||||
|
async = function(format, warg, callback)
|
||||||
|
if warg == nil then warg = 7634 end -- fallback to default hddtemp port
|
||||||
-- {{{ HDD Temperature widget type
|
local hdd_temp = {} -- get info from the hddtemp daemon
|
||||||
local function worker(format, warg)
|
spawn.with_line_callback_with_shell(
|
||||||
-- Fallback to default hddtemp port
|
"echo | curl -fs telnet://127.0.0.1:" .. warg,
|
||||||
if warg == nil then warg = 7634 end
|
{ stdout = function (line)
|
||||||
|
for d, t in line:gmatch"|([%/%w]+)|.-|(%d+)|[CF]|" do
|
||||||
local hdd_temp = {} -- Get info from the hddtemp daemon
|
hdd_temp["{"..d.."}"] = tonumber(t)
|
||||||
local quoted = helpers.shellquote(warg)
|
end
|
||||||
local f = io.popen("echo | curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:"..quoted)
|
end,
|
||||||
|
output_done = function () callback(hdd_temp) end })
|
||||||
for line in f:lines() do
|
end }
|
||||||
for d, t in string.gmatch(line, "|([%/%a%d]+)|.-|([%d]+)|[CF]+|") do
|
|
||||||
hdd_temp["{"..d.."}"] = tonumber(t)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
return hdd_temp
|
|
||||||
end
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
return setmetatable(hddtemp_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
Loading…
Reference in New Issue