awful: add pread() function

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-04 10:55:27 +02:00
parent 5e9e28e205
commit 03dffd34dd
1 changed files with 12 additions and 0 deletions

View File

@ -844,6 +844,18 @@ function spawn(cmd, screen)
end
end
-- Read a program output and returns its output as a string.
-- @param cmd The command to run.
-- @return A string with the program output.
function pread(cmd)
if cmd and cmd ~= "" then
local f = io.popen(cmd, 'r')
local s = f:read("*all")
f:close()
return s
end
end
--- Eval Lua code.
-- @return The return value of Lua code.
function eval(s)