Skip to content

Commit

Permalink
Merge pull request #542 from prey/Fix-volume-unmute-to-hundred
Browse files Browse the repository at this point in the history
Fixes action 'alarm'; Unmute and volume to a 100 %.
  • Loading branch information
javo authored Jan 26, 2022
2 parents ec9c2a1 + a5223ba commit fa9a1b0
Show file tree
Hide file tree
Showing 3 changed files with 2,785 additions and 26 deletions.
15 changes: 13 additions & 2 deletions lib/agent/actions/alarm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ var fs = require('fs'),
os_name = process.platform.replace('darwin', 'mac').replace('win32', 'windows'),
commands = require('./' + os_name),
Emitter = require('events').EventEmitter,
system = require('./../../common').system;
common = require('./../../common'),
logger = common.logger.prefix('actions'),
system = common.system;

var child,
emitter,
raise_interval;

exports.start = function(id, options, cb) {

var error,
self = this,
returned = 0;
Expand All @@ -38,6 +39,16 @@ exports.start = function(id, options, cb) {
}

var raise_volume = function(cb) {
if (os_name == 'linux'){
const unmuteRaiseCommands = commands.raise_volume.split('&&');
if(unmuteRaiseCommands.length < 2) return;
system.run_as_logged_user(unmuteRaiseCommands[0], [], (err) => {
if (err)
logger.info(`ERROR while raising volume: ${err}`);
system.run_as_logged_user(unmuteRaiseCommands[1], [], cb);
});
return;
}
exec(commands.raise_volume, cb);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/agent/actions/alarm/linux.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
exports.play = 'mpg123';
exports.raise_volume = 'pactl set-sink-mute 0 0 && pactl set-sink-volume 0 65536';
exports.raise_volume = 'pactl set-sink-mute @DEFAULT_SINK@ 0&&pactl set-sink-volume @DEFAULT_SINK@ 100%';
Loading

0 comments on commit fa9a1b0

Please sign in to comment.