The solution with event system is the clean way that would survive updates. The one liner is a hack in the firmware source directly.
It is all in driver.cpp
void LaserDriver::changeIntensity(secondspeed_t newIntensity) {
#if defined(DOOR_PIN) && DOOR_PIN > -1
if (Printer::isDoorOpen()) {
newIntensity = 0; // force laser off if door is open
}
#endif
if (EVENT_SET_LASER(newIntensity)) {
// Default implementation
#if LASER_PIN > -1
WRITE(LASER_PIN, (LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
#endif
}
intens = newIntensity; // for "Transfer" Status Page
}
that is the original source. You see with events it can be overridden. Or you replace
WRITE(LASER_PIN, (LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
with
analogWrite(LASER_PIN, newIntensity) ;
analogWrite is a arduino function that sets hardware pwm using the correct time. But is also unknowing about firmware timers used so it will just modify timer settings if that pin uses timer 0-3. And if pin has no timer it won't work.