Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ env:
# allow commonjs module definition globals (e.g. require, module.exports)
commonjs: true
mocha: true
es6: true


parserOptions:
ecmaVersion: 6


globals:
49 changes: 39 additions & 10 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
var pjson = require('./package.json'),
Extension = require('openframe-extension'),
execSync = require('child_process').execSync,
debug = require('debug')('openframe-website');
debug = require('debug')('openframe-website'),
psList = require('ps-list');

/**
* Extensions should expose an instance of the Extension class.
Expand All @@ -17,16 +18,44 @@ module.exports = new Extension({
'display_name': 'Website',
'download': false,
'start_command': function(args, tokens) {
// 1. clone template .xinitrc
var filePath = _cloneTemplate(this.xinitrcTplPath),
// 2. parse options from args into tokens
_tokens = _extendTokens(args, tokens);
// 3. replace tokens in .xinitrc
_replaceTokens(filePath, _tokens);
// 4. return xinit
return 'xinit ' + filePath;
return new Promise(function(resolve, reject) {
// is X server running?
psList().then(function(processes) {
processes = processes.filter(function(process) { process.name.indexOf('Xorg') > -1; });
let commandLineMode = processes.length > 0;

// parse options from args into tokens
let _tokens = _extendTokens(args, tokens);

// command line mode
if (commandLineMode) {
// clone template .xinitrc
var filePath = _cloneTemplate(this.xinitrcTplPath);
// replace tokens in .xinitrc
_replaceTokens(filePath, _tokens);
// return xinit
resolve('xinit ' + filePath);
}
// desktop mode
else {

// var command = '/usr/bin/chromium --noerrdialogs --kiosk --incognito $flags "$url"'
var command = '/usr/bin/chromium --noerrdialogs --incognito --kiosk '
// _tokens['$flags'].forEach(function(flag, index) {
// command += '--' + flag + ' ';
// })
command += _tokens['$url']
// console.log(command)
resolve(command);
}
});


});

},
'end_command': 'pkill -f X',
// 'end_command': 'pkill -f X',
'end_command': 'pkill -f chromium', // TODO: kill x server in command line mode
xinitrcTplPath: __dirname + '/scripts/.xinitrc.tpl'
},
});
Expand Down
Loading