Run external script? | Intech Studio
💬 general Grid

Run external script?

timp
timp · · 13 replies

Is it possible to run external scripts (e.g. on button events) in the Grid Editor?

This might work something like this:

  • I create a script ~/grid-scripts/my-script.ts
  • In the Grid Editor I specify a terminal command to execute, e.g. node ~/grid-scripts/my-script.ts

It would be great if there was a way to pass on some context from the grid unit to the script (e.g. the value of the press event [0..127]) (maybe via string replacement), e.g.:

node ~/grid-scripts/my-script.ts %self.button_value()%

In addition to that it would be great if the error stream of the script was captured in the grid editor for debugging. So if the script produces an error it would be easy to debug it.

Replies (13)

kkerti kkerti ·

We don't have direct terminal execution build into action blocks, but I just made a package inspired by your https://discord.com/channels/761513181696098335/1416411953118580736 question.

kkerti kkerti ·

The macOS demo package I made uses node's exec like this:

  // ...deleted code for simplicity
  const command = `osascript -e "set volume output volume ${vol}"`;
  exec(command, { timeout: 2000 }, (error, stdout, stderr) => {
      console.log(`Volume set to ${vol}`);
  })
kkerti kkerti ·
kkerti kkerti ·

In the index.js I am basically just using the exports.sendMessage = ... callback, which listens to any message sent from Grid Editor, where the triggered message is coming from a gps("package-macos-volume" ...) action call.

kkerti kkerti ·

An other important part of the code is exports.loadPackage where a custom action block is passed for Editor to register it under the add action block mechanism.

kkerti kkerti ·

If you want to try and make your own package, read the above linked's package readme and rename everything which starts with package-macos-volume to package-WHATEVER. I suspect even action blocks should have unique names, but they also have their own ids, so I might be wrong there, this system contiously changed as we built the first couple packages

kkerti kkerti ·

Also although Grid Editor and a package can communicate back and forth, my macos demo only listens to messages sent from the Editor, it does not send back anything.

kkerti kkerti ·

For examples on sending info back, you can look into the public intechstudio repositories which start with the name package-.

kkerti kkerti ·

But as we mentioned with Dani in a different thread, next week we'll try to document the barebones essentials to get properly started and plan to make a basic websocket based demo project.

timp timp ·

Wow, thanks a lot for the demo project! I'm super new to the Grid Editor. I installed your package, dropped the Volume Control utility into the "Endless" column. But I am not sure what to use for val. I tried replacing it with self:endless_value(), but that causes an error.
When I replace val with a number, it works (but is not dynamically changing, as expected). I am not sure how to assign the value from the knob to the utility.

next week we'll try to document the barebones essentials to get properly started and plan to make a basic websocket based demo project.

That's great! Looking forward to it!

CleanShot_2025-09-14_at_14.44.072x.png
kkerti kkerti ·

Look for the profile for vsn1 with the name macos system volume and upload that to the module

kkerti kkerti ·

Here val as it is now is undefined (nil), so directly you could add a locals action block or code block to make a value assignment like local val = self:endless_value()

timp timp ·

Ah, got it. Now it's working! Thanks a lot!

Discord

View on Discord

This post is from the Intech Studio Discord community.

Open thread →