From b51538f40397eaa16c42773001c55278d0cbbcea Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Tue, 2 Jun 2020 00:22:04 +0200 Subject: [PATCH 1/5] Fixes #1 automatic installation on Pi 1 and 2 --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 837a676..7c3b56f 100755 --- a/install.sh +++ b/install.sh @@ -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/" From b03e827a6a6ede26d03d2ea1d84f6dde751ea3ff Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Sat, 20 Jun 2020 19:47:13 +0200 Subject: [PATCH 2/5] Disable killing X --- extension.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extension.js b/extension.js index eada459..867a603 100644 --- a/extension.js +++ b/extension.js @@ -57,7 +57,8 @@ module.exports = new Extension({ }) }, // 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) From be50eb5d70170aa80b9e3225aa81e1de2f06cbca Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Sat, 20 Jun 2020 20:02:55 +0200 Subject: [PATCH 3/5] Attempt to switch to desktop mode --- extension.js | 65 ++++++++++++++++++++++++++++++++++++---------------- package.json | 3 ++- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/extension.js b/extension.js index 867a603..8742167 100644 --- a/extension.js +++ b/extension.js @@ -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 @@ -35,25 +36,49 @@ 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; + + // parse options from args into tokens + let _tokens = _extendTokens(args, tokens); + + 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/bin/chromium --noerrdialogs --kiosk --incognito $flags "$url"' + var command = '/usr/local/bin/processing-java --present ' + // _tokens['$flags'].forEach(function(flag, index) { + // command += '--' + flag + ' '; + // }) + command += '--sketch=' + _tokens['$tmpSketchPath'] + // console.log(command) + return resolve(command); + } + }) + }); }) }, // how do we stop this type of artwork? diff --git a/package.json b/package.json index 7fc9368..4defbc6 100644 --- a/package.json +++ b/package.json @@ -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", From 020b0570a48f25330fd5b9d1322c4bcf3b1234eb Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Sat, 20 Jun 2020 20:05:44 +0200 Subject: [PATCH 4/5] Hot fix --- extension.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/extension.js b/extension.js index 8742167..4b6238a 100644 --- a/extension.js +++ b/extension.js @@ -40,9 +40,6 @@ module.exports = new Extension({ 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); prepareSketch(options, tokens).then(function(result) { tokens['$tmpSketchPath'] = result From 080d5ea2b5454ac1dba133057c46ba1c844689d3 Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Sat, 20 Jun 2020 20:26:22 +0200 Subject: [PATCH 5/5] Hot fix --- extension.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/extension.js b/extension.js index 4b6238a..0364d56 100644 --- a/extension.js +++ b/extension.js @@ -65,12 +65,9 @@ module.exports = new Extension({ // desktop mode else { - // var command = '/usr/bin/chromium --noerrdialogs --kiosk --incognito $flags "$url"' - var command = '/usr/local/bin/processing-java --present ' - // _tokens['$flags'].forEach(function(flag, index) { - // command += '--' + flag + ' '; - // }) - command += '--sketch=' + _tokens['$tmpSketchPath'] + var command = '/usr/local/bin/processing-java ' + command += '--sketch=' + _tokens['$tmpSketchPath'] + ' ' + command += '--present' // console.log(command) return resolve(command); }