-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume.js
More file actions
executable file
·60 lines (57 loc) · 2.02 KB
/
Copy pathvolume.js
File metadata and controls
executable file
·60 lines (57 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
exports.action = function (data, callback, config) {
// Verify config
config = config.modules.volume;
if (!config.os_version || (config.os_version != '32' && config.os_version != '64')) {
console.log("Invalid Volume config :" + config.os_version);
return callback({ 'tts': 'Configuration Volume invalide' });
} else {
// Set default values
config.volumeStep = '10000';
config.maxVolume = 65535;
if (config.os_version == '32') {
config.process = '%CD%/plugins/volume/bin/nircmdc.exe';
} else {
config.process = '%CD%/plugins/volume/bin/nircmdc64.exe';
}
}
var exec = require('child_process').exec;
var command = null;
var result = 'une erreur est survenue';
// Find wanted command
switch (data.soundValue) {
case 'unmute':
command = ' mutesysvolume 0';
result = 'coucou, me revoila !';
break;
case 'mute':
command = ' mutesysvolume 1';
result = '';
break;
case 'up':
command = ' changesysvolume ' + config.volumeStep;
result = 'voila, je parle plus fort !';
break;
case 'down':
command = ' changesysvolume -' + config.volumeStep;
result = 'voila, je parle moins fort.';
break;
case 'set':
// We convert percentage to system value based on max volume
var percent = (data.percentage >= 0 && data.percentage <= 100) ? data.percentage : null;
if (percent) {
var sysValue = Math.round(parseInt(percent) * config.maxVolume / 100);
command = ' setsysvolume ' + sysValue;
result = 'volume réglé.';
}
break;
default :
break;
}
if (command) {
exec(config.process + command, function (error, stdout, stderr) {
//console.log(process);
});
}
// End of action
callback({'tts': result});
}