From 7dd98195e1e20d3f98b63700284b177d7f4e0d6d Mon Sep 17 00:00:00 2001 From: ryanafrish7 Date: Wed, 7 Dec 2016 16:12:01 +0530 Subject: [PATCH 1/2] Improved linux support --- README.md | 2 +- impl/linux.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a388fe..58b3dda 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ loudness.getMuted(function (err, mute) { ## OS Support -Currently Mac OS X and Linux (ALSA) is supported, please send a pull requests if you are using another setup. +Currently Mac OS X and Linux (ALSA) is supported, please send a pull request if you are using another setup. diff --git a/impl/linux.js b/impl/linux.js index 56e50a5..096b5ac 100644 --- a/impl/linux.js +++ b/impl/linux.js @@ -101,7 +101,7 @@ module.exports.getMuted = function (cb) { }; module.exports.setMuted = function (val, cb) { - amixer(['set', 'PCM', (val?'mute':'unmute')], function (err) { + amixer(['set', '-D', 'pulse', 'Master', (val?'mute':'unmute')], function (err) { cb(err); }); }; From 468476c34c418cdf8d44c1373ef03296f3e41fb9 Mon Sep 17 00:00:00 2001 From: ryanafrish7 Date: Fri, 9 Dec 2016 23:41:24 +0530 Subject: [PATCH 2/2] ALSA & PulseAudio works --- impl/linux.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/impl/linux.js b/impl/linux.js index 096b5ac..9212d9a 100644 --- a/impl/linux.js +++ b/impl/linux.js @@ -101,7 +101,15 @@ module.exports.getMuted = function (cb) { }; module.exports.setMuted = function (val, cb) { - amixer(['set', '-D', 'pulse', 'Master', (val?'mute':'unmute')], function (err) { - cb(err); + amixer(['set', 'Master', (val?'mute':'unmute')], function (err) { + if(err) return cb(err); + + amixer(['set', '-D', 'pulse', 'Master', (val?'mute':'unmute')], function (err) { + // Ignore error if pulseaudio is not running + if(err && err.message.includes("Mixer attach pulse error: Connection refused")) + cb(); + else + cb(err); + }); }); };