Executing Sketch via Linux Command Line?

Anyone have experience using sketch to bring up what you’ve created via the linux command line?

I found this online, but it’s not working for me for some reason.

I downloaded the tgz processing file from the official site and then extracted it into my ~/ directory. From the processing IDE , if i open the sketch folder, it seems to be by default set to /tmp on my linux system, but using processing ide also creates a sketchbook folder in my home as well, but how exactly do I use the command line to execute sketch? can’t seem to get it to work :frowning:

1 Like

well, it should run, so might be that you type the command wrong?
how we could help if you not show the command / and the error you got.
like with a screenshot?

extracted processing-3.4-linux64.tgz to ~/
sketch dir = ~/home/rue/sketchbook/sketches/

i created a test.pde in ~/home/rue/sketchbook/sketches/test.pde
via text editor.

executed ./processing-java --sketch=/home/rue/sketchbook/sketches/ --force --run
like it described in the github page
however, i’m seeing this result:

https://imgur.com/a/nAsT9xM

for the install procedure??
i miss you do the install.sh thing?
what procedure you are following?

//_________________________
sorry, that would not run with IDE or from command line.

the path to the DIR of the sketch would be

/home/rue/sketchbook/sketches/test

the path to the sketch would be

/home/rue/sketchbook/sketches/test/test.pde

the call only need the path info

processing-java --sketch=/home/rue/sketchbook/sketches/test --run

also the ./ should tell linux what?

pi@RPI3BP:~ $ ./processing-java
bash: ./processing-java: No such file or directory

1 Like

hmm so seems like the file name i’m working on has to match the folder name?
so that would mean the command:

processing-java --sketch=/home/rue/sketchbook/sketches/test --run

would have to be changed every time to reflect the new file i’m working on? since the new file name will need its own identical folder name?

is there no way to just have one folder for keeping all the files?

i’m using ./ because i haven’t set the those processing shell scripts as aliases in my .bashrc so globally, the system doesn’t know about these shell scripts (commands) yet. so ./ allows the system to know i’m trying to run this particular script in this folder.

hm, possibly you should start with the IDE first
it is organizing all that for you

If you want to have a bunch of sketches in the same folder and be able to run them, you could use a bash script for launching them. Lets assume we have these files and folders somewhere on our computer:

$ ls
data/
runp5.sh
test1.pde
test2.pde

The data folder can contain images, sounds etc needed by your sketches.

I have two working sketches (test1 and test2) and then my launcher script runp5.sh that looks like this:

#!/bin/bash

# The argument with .pde removed
base=${1%.pde}

# The folder where we will store the sketch
p5path="/tmp/$base"

# Remove the folder if it exists...
rm -rf $p5path

# ...and create it again
mkdir $p5path

# Symlink the data folder
ln -s "$(realpath data)" $p5path/data

# Symlink the pde file
ln -s "$(realpath $1)" $p5path/$1

# Run!
processing-java --sketch=$p5path --run

This script must be executable (you can do chmod +x runp5.sh)

Once things are set up like this, you can launch the sketches like this:

./runp5 test1.pde
./runp5 test2.pde

What does it do? basically it creates the required folder structure to run the sketch by using symbolic links, which is nice because they are tiny so it’s not copying any huge files you may have in data. Also nice because if you edit the files inside /tmp (say with the Processing IDE) changes are reflected in their original location.

But… it won’t work if your sketch uses multiple pde files, or in other cases I haven’t thought of.

1 Like

If you are trying to script multiple sketches and don’t mind exporting them first, then here is a previous related discussion of writing a launcher script for multiple sketches.

The example launcher script is python, not bash, and it uses the self-contained app form rather than the raw sketch with processing-java.

You might also be interested in programs for managing multiple sketches, like the Processing Showcase: