-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (43 loc) · 1.55 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var async = require("async");
var child = require("child_process");
// Check if we are running on a mac and turn off
function turn_off_light_kb() {
if (process.platform.match("darwin")){
child.exec("bin/kbrightness 0");
return true;
}
}
// Check if we are running on a mac and set it bright
function turn_on_light_kb() {
if (process.platform.match("darwin")){
child.exec("bin/kbrightness 0.4");
return true;
}
}
var Stremio = require("stremio-addons");
var manifest = {
"name": "Mac Keyboard Light",
"description": "Turn off backlight from mac keyboards when playing content",
"id": "org.stremio.mackblight",
"version": require("./package").version,
"types": ["movie", "series", "channel"],
"idProperty": "imdb_id",
// OBSOLETE; used instead of types/idProperty before stremio 4.0
"filter": { "query.imdb_id": { "$exists": true }, "query.type": { "$in":["series","movie"] } }
};
var methods = { };
var addon = new Stremio.Server({
"stream.find": turn_off_light_kb,
"meta.get": turn_off_light_kb,
"meta.search": turn_on_light_kb,
"meta.find": turn_on_light_kb
}, { stremioget: true}, manifest);
// Listen to 7099 if we're stand-alone
if (require.main===module) var server = require("http").createServer(function (req, res) {
addon.middleware(req, res, function() { res.end() })
}).on("listening", function()
{
console.log("Mac Keyboard Light Addon listening on "+server.address().port);
}).listen(process.env.PORT || 7099);
// Export for local usage
module.exports = addon;