diff options
author | Noah Tilton <code@tilton.co> | 2015-02-22 11:19:34 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2015-03-28 19:45:46 +0100 |
commit | 02e1142749d219dbd6bb9af95c87a3a39ba19dc3 (patch) | |
tree | f4783bc6bb60b84834586b97832deaff1cef0ad3 /contrib | |
parent | 9c535a19bdd9c05259c57725af77a21a6d41851c (diff) | |
download | vicious-legacy-02e1142749d219dbd6bb9af95c87a3a39ba19dc3.tar.xz |
handle case if pacmd fails
Signed-off-by: Jörg Thalheim <joerg@higgsboson.tk>
Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/pulse.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/pulse.lua b/contrib/pulse.lua index 413b767..b06bf56 100644 --- a/contrib/pulse.lua +++ b/contrib/pulse.lua @@ -30,9 +30,13 @@ local pulse = {} -- {{{ Helper function local function pacmd(args) local f = io.popen("pacmd "..args) - local line = f:read("*all") - f:close() - return line + if f == nil then + return nil + else + local line = f:read("*all") + f:close() + return line + end end local function escape(text) @@ -48,6 +52,7 @@ local function get_sink_name(sink) -- Cache requests if not cached_sinks[key] then local line = pacmd("list-sinks") + if line == nil then return nil end for s in string.gmatch(line, "name: <(.-)>") do table.insert(cached_sinks, s) end @@ -66,6 +71,7 @@ local function worker(format, sink) -- Get sink data 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 string.find(data,"set%-sink%-mute "..escape(sink).." yes") then |