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
62 changes: 41 additions & 21 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var pjson = require('./package.json'),
path = require('path'),
DecompressZip = require('decompress-zip'),
replace = require('replace-in-file'),
os = require('os')
os = require('os'),
psList = require('ps-list');

let tmpDir = '/tmp/'
// TODO: the preferences are stored in different path on each OS. This currently only works on the Pi
Expand Down Expand Up @@ -35,29 +36,48 @@ module.exports = new Extension({
'start_command': function(options, tokens) {
var thisExtension = this
return new Promise(function(resolve, reject) {

prepareSketch(options, tokens).then(function(result) {
tokens['$tmpSketchPath'] = result

// 1. clone template .xinitrc
debug('clone template')
var filePath = _cloneTemplate(thisExtension.xinitrcTplPath)
// 2. parse options from options into tokens
debug('extend tokens')
var _tokens = _extendTokens(options, tokens)
// 3. replace tokens in .xinitrc
debug('replace tokens')
_replaceTokens(filePath, _tokens)
// 4. return xinit
debug('build command')
var command = 'xinit ' + filePath
// console.log(command)
return resolve(command)
})
// is X server running?
psList().then(function(processes) {
processes = processes.filter(function(process) { process.name.indexOf('Xorg') > -1; });
let commandLineMode = processes.length > 0;

prepareSketch(options, tokens).then(function(result) {
tokens['$tmpSketchPath'] = result

// 1. clone template .xinitrc
debug('clone template')
var filePath = _cloneTemplate(thisExtension.xinitrcTplPath)
// 2. parse options from options into tokens
debug('extend tokens')
var _tokens = _extendTokens(options, tokens)
// 3. replace tokens in .xinitrc
debug('replace tokens')
_replaceTokens(filePath, _tokens)
// 4. return xinit
debug('build command')

// command line mode
if (commandLineMode) {
var command = 'xinit ' + filePath
// console.log(command)
return resolve(command)
}
// desktop mode
else {

var command = '/usr/local/bin/processing-java '
command += '--sketch=' + _tokens['$tmpSketchPath'] + ' '
command += '--present'
// console.log(command)
return resolve(command);
}
})
});
})
},
// how do we stop this type of artwork?
'end_command': 'pkill -f X && pkill -f java',
// 'end_command': 'pkill -f X && pkill -f java',
'end_command': 'pkill -f java',
// function () {
// // cleanUp()
// console.log(end_command)
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [ $os == "Linux" ]; then

# on Linux distributions
# on RaspberryPi
if [ $arq == "armv7l" ]; then
if [ $arq == "armv7l" ] || [ $arq == "armv6l" ]; then
curl https://processing.org/download/install-arm.sh | sudo sh
else
echo "Install Processing manually from: https://processing.org/download/"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"fs-extra": "^8.1.0",
"openframe-extension": "^0.1.0",
"replace-in-file": "^4.1.3",
"unzip": "^0.1.11"
"unzip": "^0.1.11",
"ps-list": "^5.0.1"
},
"repository": {
"type": "git",
Expand Down