forked from OpenframeProject/Openframe-Image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
57 lines (48 loc) · 1.93 KB
/
extension.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
54
55
56
57
var pjson = require('./package.json'),
debug = require('debug')('openframe:image'),
Extension = require('openframe-extension');
/**
* Extension initialization method.
*
* Called when the extension (and its dependencies) have been installed.
*
* @param {object} OF An interface provided to extensions giving limited access to the frame environment
*/
module.exports = new Extension({
format: {
// the name should be the same as the package name
'name': pjson.name,
// this is what might get displayed to users
'display_name': 'Image',
// does this type of artwork need to be downloaded to the frame?
'download': true,
// how do start this type of artwork? currently two token replacements, $filepath and $url
'start_command': function(custom_opts) {
debug('Artwork config: ', custom_opts);
var command = 'i2fb',
default_opts = {
'--fill': 'screen' // fill the entire screen (other options: 'image', 'width', 'height');
},
opts,
key;
if (custom_opts && typeof custom_opts === 'object') {
opts = Object.assign(default_opts, custom_opts);
} else {
opts = default_opts;
}
for (key in opts) {
if (typeof opts[key] === 'boolean') {
// if the value is boolean, include it as a flag if it's true
command += opts[key] ? ' ' + key : '';
} else {
// for all other arguments, assume strings and pass as arguments with values
command += ' ' + [key, opts[key].toString()].join(' ');
}
}
command += ' $filepath';
return command;
},
// how do we stop this type of artwork?
'end_command': 'sudo pkill -f i2fb'
}
});