Hi. Im using LightBurn for generating gcode. Most of preset machine have persistent power so gcode have S power only on change. It will be good if M5 lock the output so none of G1 movements turn on laser. M3 without without Sxxx could unlock laser with previously setup power or with S to set new power. But Laser would only turn on with G1 movement. If S is included in G1 new power is set up. G0 cannot reset power.
Now im using custom written program convert gcode. It reads line by line and if S power param is in this line i stor it, If G1 line without S i add S with stored power at the end.