From 065c0b83dd94bff20aaabcc8aca13c4553457f81 Mon Sep 17 00:00:00 2001 From: Nicolas Hurtubise <316k@legtux.org> Date: Tue, 16 Sep 2014 00:54:58 -0400 Subject: [PATCH] Unmute the sound on info requests --- opt/lrc-server/lrc.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/opt/lrc-server/lrc.js b/opt/lrc-server/lrc.js index 67b2160..ad56103 100644 --- a/opt/lrc-server/lrc.js +++ b/opt/lrc-server/lrc.js @@ -100,10 +100,17 @@ app.get(/^\/(.*)/, function(req, res) { volume = volume[0].split("["); volume = volume[1]; - var backlight = stdout.split("[on]"); - backlight = backlight[1].replace(/^\s+|\s+$/g, ""); + var backlight = stdout.split(/\[o(?:n|ff)\]/); // Matches [on] or [off] + + // Unmute the speakers + if(stdout.indexOf("[off]") != -1) { + exec("amixer sset Master unmute"); + } + + backlight = backlight[backlight.length-1].trim(); backlight = backlight.split("."); backlight = backlight[0]; + res.send(req.query.callback + "({'volume':'" + volume + "', 'backlight':'" + backlight + "'})"); } else { res.send(req.query.callback + "()");