This depends on whether you need to detect only “not IDA GUI”, or specifically “idalib context”, since you can also have idat, or a separate Python process.
This depends on whether you need to detect only “not IDA GUI”, or specifically “idalib context”, since you can also have idat, or a separate Python process.