The python script is has auto mode for detecting the external monitors connected so it softly turn-off Builtin Monitor without closing lid. Then it detects when user un-plugged all externals from Macbook then turn on the Builtin Monitor back
Usage :
Auto detection mode
python3 display.py auto