forked from slametps/MMM-PrayerTime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_helper.js
38 lines (35 loc) · 1.04 KB
/
node_helper.js
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
/* Magic Mirror
* Node Helper: MMM-PrayerTime
*
* By Slamet PS/slametps@gmail.com
* MIT Licensed.
*/
var NodeHelper = require("node_helper");
var async = require('async');
var exec = require('child_process').exec;
module.exports = NodeHelper.create({
// Subclass start method.
start: function() {
console.log("Starting node_helper.js for MMM-PrayerTime.");
},
socketNotificationReceived: function(notification, payload) {
console.log(this.name + " node helper received a socket notification: " + notification + " - Payload: " + payload);
if (notification == "PLAY_ADZAN") {
var adzanSound = 'adzan.mp3';
if (payload.occasion) {
if (payload.occasion=="FAJR") {
adzanSound = 'adzan-fajr.mp3';
}
else if (payload.occasion=="IMSAK") {
adzanSound = 'imsak.mp3';
}
}
var adzanCmd = '/usr/bin/omxplayer -o both modules/MMM-PrayerTime/res/' + adzanSound + ' &';
async.parallel([
async.apply(exec, adzanCmd)
],
function (err, res) {
});
}
},
});