handle case if pacmd fails
Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk> Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
This commit is contained in:
parent
9c535a19bd
commit
02e1142749
|
@ -30,9 +30,13 @@ local pulse = {}
|
||||||
-- {{{ Helper function
|
-- {{{ Helper function
|
||||||
local function pacmd(args)
|
local function pacmd(args)
|
||||||
local f = io.popen("pacmd "..args)
|
local f = io.popen("pacmd "..args)
|
||||||
|
if f == nil then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
local line = f:read("*all")
|
local line = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function escape(text)
|
local function escape(text)
|
||||||
|
@ -48,6 +52,7 @@ local function get_sink_name(sink)
|
||||||
-- Cache requests
|
-- Cache requests
|
||||||
if not cached_sinks[key] then
|
if not cached_sinks[key] then
|
||||||
local line = pacmd("list-sinks")
|
local line = pacmd("list-sinks")
|
||||||
|
if line == nil then return nil end
|
||||||
for s in string.gmatch(line, "name: <(.-)>") do
|
for s in string.gmatch(line, "name: <(.-)>") do
|
||||||
table.insert(cached_sinks, s)
|
table.insert(cached_sinks, s)
|
||||||
end
|
end
|
||||||
|
@ -66,6 +71,7 @@ local function worker(format, sink)
|
||||||
|
|
||||||
-- Get sink data
|
-- Get sink data
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
|
if sink == nil then return {0, "unknown"} end
|
||||||
|
|
||||||
-- If mute return 0 (not "Mute") so we don't break progressbars
|
-- If mute return 0 (not "Mute") so we don't break progressbars
|
||||||
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
||||||
|
|
Loading…
Reference in New Issue