[solved] How to know Defold editor is loaded?

Hello,

I’m writing a shell script (linux) for resizing Defold’s editor windows once it’s loaded.

How to know Defold has finished loading the editor ?

Launching the editor is non-blocking. For the moment, i’m just sleeping the script for 10 seconds, but i’d like more accurate method.
I’ve tried to watch process id with « ps » command, but it seems everything is launched at the beginning.

Thank you for any idea.

Have you tried doing it from an editor script?

There is no lifecycle hook for what you want, but you can test if when the script itself is called the editor is already loaded enough for you to resize.

1 Like

Hello,

Thank you for your suggestion.

Finally, i found another way to do it: at startup, Defold launches an internal webserver (its connection port changes all time, must be used from inside the editor).
Once you can connect to it, then the editor windows is here.

(note: /tmp/launch_defold is the log of the editor, redirected in a file and stdout with tee command)

Defold is launched with its STDERR redirected to STDOUT, and to a file i parse, with tee command with the following script part.

# is the web server launched ?
uri_serveur_http=""
while [ "${uri_serveur_http}" == "" ]; do
  sleep 0.5
  uri_serveur_http=$(sed '/localhost:/!d;s/.*http:\([^\"]\+\).*/http:\1/' /tmp/launch_defold)
done

# does the web server answer ?
while [ "$(curl -s ${uri_serveur_http})" == "" ]; do
  sleep 0.5
done
1 Like