From 79b48db4ef04c464898208df7639123f61b35781 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 8 May 2015 23:45:08 +0200 Subject: volume widget: handle amix errors --- widgets/volume.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/widgets/volume.lua b/widgets/volume.lua index a9a6437..122714a 100644 --- a/widgets/volume.lua +++ b/widgets/volume.lua @@ -22,13 +22,17 @@ local function mixercommand(w, command) local fd = io.popen(cmd .. command) local status = fd:read("*all") fd:close() - local volume = string.match(status, "(%d?%d?%d)%%") - status = string.match(status, "%[(o[^%]]*)%]") - w:set_value(tonumber(volume)) - if string.find(status, "on", 1, true) then - w:set_border_color(beautiful.fg_normal) - else - w:set_border_color(beautiful.bg_normal) + if status == '' then + w.widget.visible = false + else + local volume = string.match(status, "(%d?%d?%d)%%") + status = string.match(status, "%[(o[^%]]*)%]") + w:set_value(tonumber(volume)) + if string.find(status, "on", 1, true) then + w:set_border_color(beautiful.fg_normal) + else + w:set_border_color(beautiful.bg_normal) + end end end -- cgit v1.2.3