When I run any GUI application on Linux (Ubuntu) using sudo command from the Terminal, the application fails with QT error as below.
Almost every application fails when attempted; here is an example for firefox
As sudo/root doesn't have DISPLAY by default, On setting the display this works Ref: Running GUI application as another (non-root) user
Is it possible to identify that the application doesn't have display and set this programmmatically?