Custom GCode for status changes

Simple idea, in printer.cfg allow custom GCode(or a subset of GCodes) for certain status changes, so that for example neopixel devices can display different colors depending on machine state.

State changes I would like to see:
Homing [X,Y,Z] (3 states)
Connected to host,
Disconnected from host,
M112 triggered,
Waiting on bed/hotend (heating, cooling, etc) to reach temperature

Maybe instead of GCode a map of RGBWI values

[neopixel myFysetc12864]
status_colors: myStatusColors

[led_colors myStatusColors]
on_m112: 
    1.0, 0.0, 0.0, 0.0, 1.0 #R,G,B,W,I
    1.0, 0.0, 0.0, 0.0, 2.0
on_bed_heating:
    1.0, 0.5, 0.0, 0.0, 1.0
    1.0, 0.5, 0.0, 0.0, 2.0
on_extruder0_heating:
    ...
on_host_connected:
    0.0, 1.0, 0.0, 0.0, 1.0