Conditional for "Hotend temp reached" to use in gcode script?

I would like to have a short M300 "beep" when the "real" print starts (only before the first production move - not at the first homing, etc) to get my attention when the first layer is printed.

In my start gcode in Cura this works fine when I insert it after the M109 command. But to have it also in already sliced files I would prefer to have it in the OctoPrint gcode "Before print job starts".

So I think I must use some conditional like "if hotenend-temp is reached" to realize that.
I read about this "last_temperature" thing in the docs, but have no clue if - and when - how I can use this.

I'm grateful for any help in this.

If you want a "beep" before the first layer starts, add the M300 to the end of your start gcode. In already sliced files, I'm afraid you'll have to do some "manual" editing. If your start gcode has an M117 command at the end (or anything else that is a constant), you could write a "sed" command to automate the editing of existing gcode files ("man sed" or "info sed").

Unfortunately, "Before print job starts" is actually "before" the gcode file is sent to the printer, which means "before" the start gcode is executed.

If you want a "beep" at the end of the first layer, then either "sed" or a post processing script in your slicer will be needed.

Ah, ok, didn't realize that. So my initial idea is obsolete.
For fresh sliced files I can use cura's start gcode (no problem).
For already sliced files, think I have to digg a bit deeper in "sed" how to use it for the needed modification.

If you were to post (the last few lines of) your before and after start gcode, I'd be willing to bet that someone (not necessarily me) might post a sample sed line you could use.

Thanks a lot for the tip with"sed".
Figured it out:
1.) I have a fix point ";LAYER:0" after that I can insert my M300.
2.) All the previously sliced file fortunately are in subfolders
so with
sed -i 's/;LAYER:0/;LAYER:0\nM300 S880 P50/' *.gcode
I can modify once all files per folder and all is fine :blush: